public List<TreeNode> helper(int begin, int end) {
        List<TreeNode> sub = new ArrayList<>();
        if (begin > end) {
            sub.add(null);
            return sub;
        }

        for (int i = begin; i <= end; ++i) {
            List<TreeNode> left = helper(begin, i - 1);
            List<TreeNode> right = helper(i + 1, end);
            for (int j = 0; j < left.size(); ++j) {
                for (int k = 0; k < right.size(); ++k) {
                    TreeNode root = new TreeNode(i);
                    root.left = left.get(j);
                    root.right = right.get(k);
                    sub.add(root);
                }
            }
        }
        return sub;
    }