Queue<TreeNode> queue = new LinkedList<TreeNode>(); queue.offer(root); while (!queue.isEmpty()) { int node = queue.poll(); for (int i=0; i<node.childs.size(); i++) { queue.offer(node.childs.get(i)); } }