class Solution {public int rob(TreeNode root) {if (root == null) {return 0;}if (root.left == null && root.right == null) {return root.val;}if (root.left != null && root.right != null) {return Math.max(rob(root.left) + rob(root.right), root.val + rob(root.left.left) + rob(root.left.right) + rob(root.right.left) + rob(root.right.right));}if (root.left != null) {return Math.max(rob(root.left) + rob(root.right), root.val + rob(root.left.left) + rob(root.left.right));}return Math.max(rob(root.left) + rob(root.right), root.val + rob(root.right.left) + rob(root.right.right));}
}