使用栈从头push进去,再pop出来
static void tailPrint(TreeNode node) {
Stack<TreeNode> stack = new Stack<>();
TreeNode temp = node;
while (temp.left != null) {
stack.push(temp);
temp = temp.left;
}
while (!stack.isEmpty()) {
System.out.println(stack.pop());
}
}