<prompt> Kutokana na mizizi ya mti binary, inverts mti, na kurudi mizizi yake.  <response>: To invert a binary tree, we need to swap all left and right child nodes of the tree, starting from the root. Here is an algorithm to do that:1. Check if the root node is null, if so then return null.2. Swap the left and right child nodes of the root node.3. Recursively invert the left subtree, using the new right child node as the root.4. Recursively invert the right subtree, using the new left child node as the root.5. Return the new root node.Here is the implementation of the algorithm in Python:class TreeNode: def __init__self, val0, leftNone, rightNone: self.val val self.left left self.right rightdef invertTreeroot: TreeNode - TreeNode: if not root: return None swap left and right child nodes root.left, root.right root.right, root.left recursively invert left and right subtrees invertTreeroot.left invertTreeroot.right return rootNote that we swap the left and right child nodes using the tuple assignment syntax in Python, which simplifies the code. 