Example 1

Example 2

The number of nodes in the tree is in the range [1, 5000].1 <= Node.val <= 107root is a binary search tree.1 <= val <= 107Example 1

Example 2

The number of nodes in the tree is in the range [1, 5000].1 <= Node.val <= 107root is a binary search tree.1 <= val <= 107