very simple 4 lines C++ solution
\nclass Solution {\npublic:\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        if(!root1&&!root2) return true;\n        if(!root1&&root2||!root2&&
```\nclass Solution {\npublic:\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        if(!root1&&!root2) return true;\n        if(!root1&&root2||!root2&&root1) return false;\n        if(root1->val!=root2->val) return false;\n        return (flipEquiv(root1->left,root2->right)&flipEquiv(root1->right,root2->left))|(flipEquiv(root1->left,root2->left)&flipEquiv(root1->right,root2->right));        \n    }\n};\n```
[]