Checking the binary search tree condition