Given a binary search tree, you are asked to find the most common element (the mode) of the values in the binary search tree.
Equal values are always stored on the right subtree of the node. So, if the value of a child node is equal to its parent’s value, it’s guaranteed that the child is the right child. Note that equal values are not always guaranteed to appear right next to each other.
Input
The input is handled automatically, you don’t need to do anything. It’s guaranteed that the input binary tree is valid.
Output
The program should print the most common element of the values in the binary search tree. If there are several such answers, the program should print the smallest one.