Java| 0MS 100% FASTER | WITH COMMENTS
\nclass Solution {\n    TreeNode root1;\n    public TreeNode subtreeWithAllDeepest(TreeNode root) {\n        int d=depth(root);\n        helper(root,d,0);\n    
```\nclass Solution {\n    TreeNode root1;\n    public TreeNode subtreeWithAllDeepest(TreeNode root) {\n        int d=depth(root);\n        helper(root,d,0);\n        return root1;\n    }\n    public int helper(TreeNode root,int level,int last)\n    {\n        if(root==null)\n        {\n            return last;\n        }\n        \n        int l=helper(root.left,level,last+1);\n        int r=helper(root.right,level,last+1);\n        \n        if(l==level && r==level) //it will take us to last mode or deepest node\n        {\n            root1=root;                                     \n        }\n        return Math.max(l,r);\n        \n    }\n    public int depth(TreeNode root) // it is used to find max depth or last level of nodes\n    {\n        if(root==null)\n        {\n            return 0;\n        }\n        int l=depth(root.left);\n        int r=depth(root.right);\n        int th=Math.max(l,r)+1;\n        return th;\n    }\n}\n        \n        \n    \n\n```
['Depth-First Search', 'Java']