Python O(n) by DFS [w/ Comment]
Python O(n) by DFS \n\n---\n\nImplementation:\n\n\nclass Solution:\n    def subtreeWithAllDeepest(self, root: TreeNode) -> TreeNode:\n        \n        # ------
Python O(n) by DFS \n\n---\n\n**Implementation**:\n\n```\nclass Solution:\n    def subtreeWithAllDeepest(self, root: TreeNode) -> TreeNode:\n        \n        # --------------------------------------------\n        def helper(node: TreeNode) -> (int, TreeNode):\n            \n            # first return item is depth\n            # second return item is root of smallest subtree with deepest nooes\n            \n            if not node:\n\t\t\t\n                # base case\n                # empty node or empty tree\n                return 0, None\n            \n            l_depth, l_node = helper(node.left)\n            r_depth, r_node = helper(node.right)\n            \n            if l_depth > r_depth:\n\t\t\t\n                # left subtree is deeper\n                return l_depth+1, l_node\n            \n            elif r_depth > l_depth:\n\t\t\t\n                # right subtree is deeper\n                return r_depth+1, r_node\n            \n            else:\n\t\t\t\n                # both subtrees are the same\n                # current node is the root of smallest subtree with deepest nodes\n                return l_depth+1, node\n            \n        # --------------------------------------------\n        \n        # second return item is the answer\n        return helper(root)[1]\n```\n\n---\n\nRelated leetcode challenge:\n\n[Leetcode #104 Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)
['Depth-First Search', 'Recursion', 'Python', 'Python3']