def rangeSumBST(self, root: Optional[TreeNode], low: int, high: int) -> int:
def rec(node):
nonlocal total
if not node:
return
if low <= node.val <= high:
total += node.val
if node.val >= low:
rec(node.left)
if node.val <= high:
rec(node.right)
total = 0
rec(root)
return total