Code to check if a given tree is a binary search tree