UniqueBinarySearchTreesII-refactor the code