Easy understanding with comments - Java
\nclass Solution {\n    public int rob(TreeNode root) {\n        if(root == null)\n            return 0;\n        \n        //maintain this to avoid repetitive 
```\nclass Solution {\n    public int rob(TreeNode root) {\n        if(root == null)\n            return 0;\n        \n        //maintain this to avoid repetitive subproblem calculations\n        HashMap<TreeNode, Integer> memo = new HashMap<>();\n        return robRecursive(root, memo);\n    }\n    \n    public int robRecursive(TreeNode node, HashMap<TreeNode, Integer> memo){\n        if(node == null)\n            return 0;\n        \n        //If already calculated, return the result for that node\n        if(memo.containsKey(node))\n            return memo.get(node);\n        \n        // Selecting current house and skipping it\'s children if children is not NULL, call its grand children instead, if children is NULL, take 0\n        int robCurrentHouse = node.val +\n            (node.left == null? 0: robRecursive(node.left.left, memo) + robRecursive(node.left.right,memo)) +\n            (node.right == null? 0: robRecursive(node.right.left, memo) + robRecursive(node.right.right,memo));\n         \n        //If we are skipping current house, lets consider it\'s children\n        int skipCurrentHouse = robRecursive(node.left, memo) + robRecursive(node.right, memo);\n        \n        //Add the newly calculated amount to the respective node on the map\n        memo.put(node, Math.max(robCurrentHouse, skipCurrentHouse));\n        \n        return Math.max(robCurrentHouse, skipCurrentHouse);\n    }\n}\n```
['Memoization', 'Java']