public static void levelOrderTraversal(TreeNode root) {
        if (root == null) return;
        Queue<TreeNode> q = new java.util.LinkedList<TreeNode>();
        q.add(root);
        while (q.isEmpty() == false) {
            TreeNode temp = q.element();
            System.out.println(temp.val);
            q.remove();
            if (temp.left != null) q.add(temp.left);
            if (temp.right != null) q.add(temp.right);
        }
    }