Python BFS solution beats 100%
Code\npython []\nclass Solution:\n    def flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool:\n        if root1 is root2:\n          
# Code\n```python []\nclass Solution:\n    def flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool:\n        if root1 is root2:\n            return True\n        if None in (root1, root2):\n            return False\n        queue1 = deque([(root1)])\n        queue2 = deque([(root2)])\n        while queue1:\n            if len(queue1) != len(queue2):\n                return False\n            node1 = queue1.popleft()\n            node2 = queue2.popleft()\n            if node1.val != node2.val:\n                return False\n            left1 = node1.left.val if node1.left else None\n            left2 = node2.left.val if node2.left else None\n            right1 = node1.right.val if node1.right else None\n            right2 = node2.right.val if node2.right else None\n            if left1 == right2 and right1 == left2:\n                node1.left, node1.right = node1.right, node1.left\n                \n            if node1.left:\n                queue1.append(node1.left)\n            if node2.left:\n                queue2.append(node2.left)\n            if node1.right:\n                queue1.append(node1.right)\n            if node2.right:\n                queue2.append(node2.right)\n        return True \n     \n```
['Python3']