private void traverse(TreeNode root, int level,
                List<List<Integer>> result) {
            if (root == null)
                return;

            if (level > result.size()) {
                result.add(new ArrayList<Integer>());
            }

            result.get(level - 1).add(root.val);
            traverse(root.left, level + 1, result);
            traverse(root.right, level + 1, result);
        }