python bfs iterative
\'\'\'class Solution:\n        \n    def flipEquiv(self, root1: TreeNode, root2: TreeNode) -> bool:\n        def equals(root1, root2):\n            if not root2
\'\'\'class Solution:\n        \n    def flipEquiv(self, root1: TreeNode, root2: TreeNode) -> bool:\n        def equals(root1, root2):\n            if not root2 and not root2:\n                return True\n            elif root1 and root2 and root1. val==root2.val:\n                return True\n            else:\n                return False\n        queue=[]\n        queue.append((root1,root2))\n        while queue:\n            curr1, curr2=queue.pop(0)\n            if curr1 is None and curr2 is None:\n                continue\n            if not curr1 or not curr2:\n                return False\n            if not(equals(curr1,curr2)):\n                return False\n            elif (equals(curr1.left,curr2.left) and equals(curr1.right,curr2.right)):\n                queue.append((curr1.left,curr2.left))\n                queue.append((curr1.right,curr2.right))\n            elif (equals(curr1.left,curr2.right) and equals(curr1.right,curr2.left)):\n                queue.append((curr1.left,curr2.right))\n                queue.append((curr1.right,curr2.left))\n            else:\n                return False\n        return True
['Breadth-First Search', 'Iterator', 'Python']