public ArrayList<TreeNode> generate(int start, int end) {

        ArrayList<TreeNode> result = new ArrayList<TreeNode>();
        if (start > end) {
            TreeNode root = null;
            result.add(root);
            return result;
        }

        for (int i = start; i <= end; i++) {
            ArrayList<TreeNode> leftList = generate(start, i - 1);
            ArrayList<TreeNode> rightList = generate(i + 1, end);

            for (int j = 0; j < leftList.size(); j++) {
                for (int k = 0; k < rightList.size(); k++) {
                    TreeNode root = new TreeNode(i);
                    root.left = leftList.get(j);
                    root.right = rightList.get(k);
                    result.add(root);
                }
            }
        }
        return result;
    }