

In a Publicis Sapient interview setting, implement a function that returns the maximum value stored in a binary search tree (BST). Use the BST property to solve the problem efficiently instead of scanning every node.
A BST is defined such that for every node, values in the left subtree are smaller and values in the right subtree are larger. Because of this property, the maximum value is always found at the rightmost node.
root, the root node of a binary search tree, or None for an empty treeNone if the tree is emptyExample 1
root = [8, 3, 10, 1, 6, null, 14]148, move right to 10, then right to 14. No further right child exists, so 14 is the maximum.Example 2
root = [5]50 <= number of nodes <= 10^5-10^9 <= Node.val <= 10^9None for an empty treeroot = [8, 3, 10, 1, 6, null, 14]Output14WhyThe rightmost path is 8 -> 10 -> 14, so 14 is the maximum value.root = [5]Output5WhyA single-node tree has only one value, so that value is the maximum.root = []OutputNoneWhyAn empty tree has no maximum value.0 <= number of nodes <= 10^5-10^9 <= Node.val <= 10^9The tree satisfies binary search tree ordering rulesReturn None if root is nulldef find_max_bst(root):