refact the code of UniqueBST