Recursively and iteratively (level order traversal) in Python
Solution 1. recursively solution\n\n\ndef isSymmetric(self, root):\n\tdef treeMatch(root1, root2):\n\t\tif not root1 and not root2:\n\t\t\treturn True\n\t\tif (
**Solution 1. recursively solution**\n\n```\ndef isSymmetric(self, root):\n\tdef treeMatch(root1, root2):\n\t\tif not root1 and not root2:\n\t\t\treturn True\n\t\tif (root1 and not root2) or (root2 and not root1):\n\t\t\treturn False\n\t\tif root1.val != root2.val:\n\t\t\treturn False\n\t\treturn treeMatch(root1.left, root2.right) and treeMatch(root1.right, root2.left)\n\treturn treeMatch(root.left, root.right)\n```\n\n**Solution 2. iteratively solution, using level order traversal**\n```\ndef isSymmetric(self, root):\n\n\tdef levelSymetric(nums):\n\t\treturn nums[:] == nums[::-1]\n\n\ttree = [root]\n\twhile tree:\n\t\tlevel = []\n\t\tfor _ in range(len(tree)):\n\t\t\ttmp = tree.pop(0)\n\t\t\tif not tmp:\n\t\t\t\tlevel.append(None)\n\t\t\telse:\n\t\t\t\tlevel.append(tmp.val)\n\t\t\t\ttree.append(tmp.left)\n\t\t\t\ttree.append(tmp.right)\n\t\tif not levelSymetric(level):\n\t\t\treturn False\n\treturn True\n```
['Binary Tree', 'Iterator', 'Python']