Simple Java dfs recursion function with explanation
First Root to Leaf: return the deep level of every node\nThen Leaf to Root: only when the its left node and right node both have the deepthest level, update the
First `Root` to `Leaf`: return the deep level of every node\nThen `Leaf` to `Root`: only when the its left node and right node both have the deepthest level, update the result node\n```Java\nclass Solution {\n    \n    int deepestLevel = 0;\n    TreeNode res = null;\n    \n    public TreeNode subtreeWithAllDeepest(TreeNode root) {\n        dfs(root, 0);\n        return res;\n    }\n    \n    private int dfs(TreeNode root, int level) {\n        if (root == null) return level;\n        \n        int leftLevel = dfs(root.left, level + 1);\n        int rightLevel = dfs(root.right, level + 1);\n        \n        int curLevel = Math.max(leftLevel, rightLevel);\n        deepestLevel = Math.max(deepestLevel, curLevel);\n        if (leftLevel == deepestLevel && rightLevel == deepestLevel)\n            res = root;\n        return curLevel;\n    }\n}\n\n```
[]