JavaScript recursion solution
Max at root is either the sum of max left subtree and max right subtree, or the sum of the root with max of left subtree children and max of right subtree child
Max at root is either the sum of max left subtree and max right subtree, or the sum of the root with max of left subtree children and max of right subtree children. The key here is that you want to return both the max at the root and the max of its children in the helper method.\n```\n/**\n * Definition for a binary tree node.\n * function TreeNode(val, left, right) {\n *     this.val = (val===undefined ? 0 : val)\n *     this.left = (left===undefined ? null : left)\n *     this.right = (right===undefined ? null : right)\n * }\n */\n/**\n * @param {TreeNode} root\n * @return {number}\n */\nvar rob = function(root) {\n    return helper(root)[0];\n};\n\nfunction helper(root){\n    if(root == null) return [0, 0];\n    const left = helper(root.left);\n    const right = helper(root.right);\n    const currMax = Math.max(left[0] + right[0], root.val + left[1] + right[1]);\n    const childrenMax = left[0] + right[0];                 \n    return [currMax, childrenMax];\n}\n```
['Recursion', 'JavaScript']