rewrite leetcode valid BST