1var trimBST = function (root, low, high) {2if (!root) return null;3if (root.val < low) root = trimBST(root.right, low, high);4else if (root.val > high) root = trimBST(root.left, low, high);5else {6root.left = trimBST(root.left, low, high);7root.right = trimBST(root.right, low, high);8}9return root;10};