TreeNode next() {
            TreeNode head = queue.poll();
            if (head == null) {
                if (!queue.isEmpty())
                    queue.offer(null);
                return null;
            }

            if (head.left != null)
                queue.offer(head.left);
            if (head.right != null)
                queue.offer(head.right);
            return head;
        }