Python, BFS + LCA
Find the deepest nodes using BFS. If there is nothing left in queues, that means all the nodes in current level are the deepest nodes. After we got all the deep
Find the deepest nodes using BFS. If there is nothing left in queues, that means all the nodes in current level are the deepest nodes. After we got all the deepest nodes, then we want find the lowest common ancestor (LCA) of all the node using recursion.\n```\nclass Solution:\n    def subtreeWithAllDeepest(self, root: TreeNode) -> TreeNode:\n        leafs = self.bfs(root)\n        return self.LCA(root, leafs)\n        \n    def bfs(self, node):\n        q = [node]\n        while q:\n            level = []\n            for i in range(len(q)):\n                node = q.pop(0)\n                if node.left:\n                    q.append(node.left)\n                if node.right:\n                    q.append(node.right)\n                level.append(node)\n            if not q:\n                return level #return a list\n        \n        \n    def LCA(self, node, nodes): #nodes going to be list of deepest nodes\n        if not node:\n            return None\n        \n        if node in nodes:\n            return node\n        \n        left = self.LCA(node.left, nodes)\n        right = self.LCA(node.right, nodes)\n        \n        if left and right:\n            return node\n        \n        else:\n            return left or right\n```
['Breadth-First Search', 'Python']