Linear time -- Python
Same logic as House Robber\n\ndef rob(self, root):\n        """\n        :type root: TreeNode\n        :rtype: int\n        """\n        def helper(root):\n    
Same logic as [House Robber](https://leetcode.com/problems/house-robber/discuss/440346/python-constant-space-O(N))\n```\ndef rob(self, root):\n        """\n        :type root: TreeNode\n        :rtype: int\n        """\n        def helper(root):\n            if not root:\n                return 0, 0 \n            \n            l_prev, l_rob = helper(root.left)\n            r_prev, r_rob = helper(root.right)\n            \n            prev = max([l_prev+r_prev, l_rob+r_rob, l_prev+r_rob, l_rob+r_prev])\n            rob = l_prev+r_prev+root.val\n            return prev, rob\n        return max(helper(root))\n```
[]