Java clear recursion solution
\npublic boolean flipEquiv(TreeNode root1, TreeNode root2) {\n        if(root1 == null && root2 == null){\n            return true;\n        }\n        if(root1
```\npublic boolean flipEquiv(TreeNode root1, TreeNode root2) {\n        if(root1 == null && root2 == null){\n            return true;\n        }\n        if(root1 == null || root2 == null){\n            return false;\n        }\n        if(root1.val != root2.val){\n            return false;\n        }\n        \n        boolean leftLeft = flipEquiv(root1.left, root2.left);\n        boolean leftRight = flipEquiv(root1.left, root2.right);\n        boolean rightLeft = flipEquiv(root1.right, root2.left);\n        boolean rightRight = flipEquiv(root1.right, root2.right);\n        \n        if((leftLeft && rightRight) || (leftRight && rightLeft)){\n            return true;\n        }\n        return false;\n    }\n```
[]