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