public class Solution { public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) { LinkedList<TreeNode> queue = new LinkedList<>(); ArrayList<Integer> result = new ArrayList<>(); queue.add(root); while(!queue.isEmpty()) { TreeNode node = queue.poll(); if(node != null) { result.add(node.val); queue.add(node.left); queue.add(node.right); } } return result; } }