Cpp Solution Using LCA
```\nclass Solution {\npublic:\n    TreeNode lca(TreeNode root,TreeNode p,TreeNode q){\n        if(!root)return NULL;\n        if(root==p || root==q)return root
```\nclass Solution {\npublic:\n    TreeNode* lca(TreeNode* root,TreeNode* p,TreeNode* q){\n        if(!root)return NULL;\n        if(root==p || root==q)return root;\n        \n        TreeNode *left=lca(root->left,p,q);\n        TreeNode *right=lca(root->right,p,q);\n        \n        if(!left)return right;\n        if(!right)return left;\n        \n        return root;\n        \n    }  \n    \n    TreeNode* subtreeWithAllDeepest(TreeNode* root) {\n        if(!root)return root;\n               \n        vector<TreeNode*>v;\n        \n        queue<TreeNode*>q;\n        q.push(root);\n        \n        while(!q.empty()){\n            int n=q.size();\n            vector<TreeNode*>a;\n            \n            for(int i=0;i<n;i++){\n                auto ptr=q.front();\n                q.pop();\n                a.push_back(ptr);\n                \n                if(ptr->left)q.push(ptr->left);\n                if(ptr->right)q.push(ptr->right);\n            }\n            v=a;\n        }\n        \n        if(v.size()==1)return v[0];\n        TreeNode* ptr=root;\n        return lca(ptr,v[0],v[v.size()-1]);\n        \n    }\n};
['C++']