Python Solution | O(n)
\n # Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         self.rig
```\n # Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         self.right = None\n\nclass Solution:\n    def subtreeWithAllDeepest(self, root: TreeNode) -> TreeNode:\n        \n        def deepestDepth(node, depth):\n            \n            if not node:\n                return node, depth\n            \n\t\t\t\n            left, leftDepth = deepestDepth(node.left, depth + 1)\n            right, rightDepth = deepestDepth(node.right, depth + 1)    \n\n\t\t\t# If the deepest node on the left subtree is deeper than the deepest node \n\t\t\t# on the right subtree return the left subtree and the left deepest depth \n            if leftDepth > rightDepth:\n                return left, leftDepth\n            \n\t\t\t# If the deepest node on the right subtree is deeper than the deepest node \n\t\t\t# on the left subtree return the right subtree and the right deepest depth \n            if rightDepth > leftDepth:\n                return right, rightDepth\n            \n\t\t\t\n\t\t\t# If the above two conditions isn\'t met, then leftDepth == rightDepth\n\t\t\t#\n\t\t\t# leftDepth equal rightDepth means that the deepest node\n\t\t\t# in the left subtree has the same depth as the deepest node \n\t\t\t# in the right subtree, as such, we should return the current node \n\t\t\t# as it is the root of the current subtree that contains the deepest \n\t\t\t# nodes on the left and right subtree.\n\t\t\t#\n\t\t\t# return statment can also be `return node, rightDepth`\n            return node, leftDepth\n            \n        return deepestDepth(root, 0)[0]\n```
['Depth-First Search', 'Python']