BinaryTreePreorderTraversal-refactor the code