Write a function to reverse a binary tree.
The function receives the root of a binary tree and must swap the left and right children of every node in place, returning the original root. Use TreeNode objects with val, left, and right fields; test inputs and outputs use level-order arrays with null for missing children.
For example, [4,2,7,1,3,6,9] becomes [4,7,2,9,6,3,1], and an empty tree remains empty.
TreeNode objectsdef reverse_binary_tree(root):