6-line simple Python solution using DFS
The dfs function returns an array, the first element means the maximum if we include the value of the current node, and the second element means the maximum if 
  The dfs function returns an array, the first element means the maximum if we include the value of the current node, and the second element means the maximum if we exclude the value of the current node.\n\n  So in the return statement, as the first element, we include the value of the current node, and we should exclude the left and right children, so we add the second element from the result of left and right children. The second element has 4 conditions, we can include the left child and include the right child, include the left child and exclude the right child..., so we return the maximum of them.\n\n    # Definition for a binary tree node.\n    # class TreeNode(object):\n    #     def __init__(self, x):\n    #         self.val = x\n    #         self.left = None\n    #         self.right = None\n    \n    class Solution(object):\n        def rob(self, root):\n            """\n            :type root: TreeNode\n            :rtype: int\n            """\n            def dfs(node):\n                if not node:\n                    return [0, 0]\n                left, right = dfs(node.left), dfs(node.right)\n                return [node.val+left[1]+right[1], max([left[0]+right[0], left[0]+right[1], left[1]+right[0], left[1]+right[1]])]\n            \n            return max(dfs(root))
['Python']