2
def maxSumBST(self, root: TreeNode) -> int:6
"""return status_of_bst, size_of_bst, left_bound, right_bound"""9
return 1, 0, None, None # this subtree is empty11
ls, l, ll, lr = traverse(root.left)12
rs, r, rl, rr = traverse(root.right)14
if ((ls == 2 and lr < root.val) or ls == 1) and (15
(rs == 2 and rl > root.val) or rs == 117
# this subtree is a BST18
size = root.val + l + r23
(ll if ll is not None else root.val),24
(rr if rr is not None else root.val),26
return 0, None, None, None # this subtree is not a BST