Add preorder method to do serialize tree