```
class Solution(object):
def rob(self, root):
def solve(root):
if not root:
return 0, 0
left, right = solve(root.left), solve(root.right)
return (root.val + left[1] + right[1]), (max(left) + max(right))
return max(solve(root))
```