struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
bool isSymmetric(TreeNode *leftNode, TreeNode *rightNode) {
if (leftNode == NULL && rightNode == NULL) return true;
if (leftNode == NULL) return false;
if (rightNode == NULL) return false;
if (leftNode->val != rightNode->val) return false;
if (!isSymmetric(leftNode->left, rightNode->right)) return false;
return isSymmetric(leftNode->right, rightNode->left);
}
bool isSymmetric(TreeNode *root) {
if (root == NULL) return true;
return isSymmetric(root->left, root->right);
}