Java Iterative BFS - easy to understand
\npublic boolean flipEquivIterative(TreeNode root1, TreeNode root2) {\n\n        Queue<TreeNode> queue = new LinkedList<>();\n\n        queue.offer(root1);\n   
```\npublic boolean flipEquivIterative(TreeNode root1, TreeNode root2) {\n\n        Queue<TreeNode> queue = new LinkedList<>();\n\n        queue.offer(root1);\n        queue.offer(root2);\n        while (!queue.isEmpty()) {\n            TreeNode curr1 = queue.poll();\n            TreeNode curr2 = queue.poll();\n\n            if (curr1 == null && curr2 == null) {\n                continue;\n            }\n            if (!equals(curr1, curr2)) {\n                return false;\n            }\n            if (isEquals(curr1.left, curr2.left) && isEquals(curr1.right, curr2.right)) {\n                queue.offer(curr1.left);\n                queue.offer(curr2.left);\n                queue.offer(curr1.right);\n                queue.offer(curr2.right);\n            } else if (isEquals(curr1.left, curr2.right) && isEquals(curr1.right, curr2.left)) {\n                queue.offer(curr1.left);\n                queue.offer(curr2.right);\n                queue.offer(curr1.right);\n                queue.offer(curr2.left);\n            } else {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    private boolean isEquals(TreeNode root1, TreeNode root2) {\n        if (root1 == null && root2 == null) {\n            return true;\n        } else if (root1 != null && root2 != null && root1.val == root2.val) {\n            return true;\n        } else {\n            return false;\n        }\n    }\n```
[]