So after I ACed the problem, I looked through the discussion page
and found that most of the code there does not reset the sum when the tree is empty and if it's empty, they just return Math.MIN_VALUE/MIN_INT.
Then I took a look at the testcases and found it does not include the empty tree case.
I think if it's empty the code should return 0 rather than a min value. Is it a bug or something? Correct me if I'm wrong please.
No. it should return min. Because, if it returns 0, you cannot figure out there is a path which sums up to 0 or the tree is empty.