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.MINVALUE/MININT.
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.