convert pre-order traversal to a binary search tree