✅ [PHP][JavaScript] Recursive & Iterative Solutions
1. Recursive Solution\nThis solution uses recursion to check if a binary tree is symmetric. The recursive helper function isMirror() checks if the two nodes of 
### 1. Recursive Solution\nThis solution uses recursion to check if a binary tree is symmetric. The recursive helper function isMirror() checks if the two nodes of the binary tree are mirror images of each other, by comparing their values, and then recursively checking if their left and right nodes are mirror images of each other. If the values are equal and the subtrees are mirrors, then the function returns true. Otherwise, it returns false.\n\nThe *time complexity* of this solution is O(n) as all nodes in the binary tree must be visited in order to determine if the tree is symmetric. \nThe *space complexity* is also O(n) as the recursive stack may contain up to n elements.\n\n\n```javascript []\nvar isSymmetric = function (root) {\n    if (root == null) return true;\n    return isMirror(root.left, root.right);\n\n    function isMirror(leftNode, rightNode) {\n        if (leftNode == null && rightNode == null) return true;\n        if (leftNode == null || rightNode == null) return false;\n        return leftNode.val === rightNode.val &&\n            isMirror(leftNode.left, rightNode.right) &&\n            isMirror(leftNode.right, rightNode.left);\n    }\n};\n```\n```PHP []\nclass Solution\n{\n    /**\n     * @param TreeNode $root\n     * @return Boolean\n     */\n    function isSymmetric(TreeNode $root): bool {\n        if ($root === null) {\n            return true;\n        }\n        return $this->isNodesMirror($root->left, $root->right);\n    }\n\n    function isNodesMirror(?TreeNode $leftNode, ?TreeNode $rightNode): bool {\n        if ($leftNode === null && $rightNode === null) {\n            return true;\n        }\n        if ($leftNode === null || $rightNode === null) {\n            return false;\n        }\n        return $leftNode->val === $rightNode->val &&\n            $this->isNodesMirror($leftNode->left, $rightNode->right) &&\n            $this->isNodesMirror($leftNode->right, $rightNode->left);\n    }\n}\n```\n\n\n### 2. Iterative Solution\nThis solution uses a Breadth-First Search approach to traverse the tree. A queue is used to store left and right nodes of the tree at each level. If the left node and right node are both null then the loop continues. If either one is null or the values of the nodes do not match then false is returned. If the values match then the left and right children of each node are pushed to the queue for comparison. If the loop completes without returning false then true is returned.\n*Time complexity*: O(n) as the algorithm visits each node once.\n*Space complexity*: O(n) as the queue stores all nodes at each level.\n\n```javascript []\nvar isSymmetric = function (root) {\n    if (root == null) return true;\n    let queue = [root.left, root.right];\n    while (queue.length > 0) {\n        let leftNode = queue.shift();\n        let rightNode = queue.shift();\n        if (leftNode == null && rightNode == null) continue;\n        if (leftNode == null ||\n            rightNode == null ||\n            leftNode.val !== rightNode.val) {\n            return false;\n        }\n        queue.push(leftNode.left, rightNode.right);\n        queue.push(leftNode.right, rightNode.left);\n    }\n    return true;\n}\n```\n```PHP []\nclass Solution\n{\n    /**\n     * @param TreeNode $root\n     * @return Boolean\n     */\n    function isSymmetric(?TreeNode $root): bool {\n        if ($root === null) {\n            return true;\n        }\n        $queue = [[$root->left, $root->right]];\n\n        while ($queue) {\n            $newQueue = [];\n            foreach ($queue as [$leftNode, $rightNode]) {\n                if ($leftNode === null && $rightNode === null) {\n                    continue;\n                }\n                if ($leftNode->val !== $rightNode->val ||\n                    $leftNode === null ||\n                    $rightNode === null) {\n                    return false;\n                }\n                $newQueue[] = [$leftNode->left, $rightNode->right];\n                $newQueue[] = [$leftNode->right, $rightNode->left];\n            }\n            $queue = $newQueue;\n        }\n        return true;\n    }\n}\n```\n\n\n\n### If my work was useful for you, please upvote\n\uD83D\uDC4D\uD83D\uDC4D\uD83D\uDC4D
['PHP', 'JavaScript']