class CombinationUtil {

    private CombinationUtil() {}

    /**
     * Creates and returns all possible combinations of the given elements.
     *
     * The order of the combinations in the stream is unspecified.
     *
     * @param <T> element type
     * @param items to combine
     * @return all possible combinations of the given elements
     */
    @SafeVarargs
    @SuppressWarnings("varargs") // Creating a List from an array is safe
    public static <T> Stream<List<T>> of(final T... items) {
        return IntStream.rangeClosed(1, items.length)
            .mapToObj(r -> {
                @SuppressWarnings("unchecked")
                final T[] data = (T[]) new Object[r];
                return combinationHelper(items, data, 0, items.length - 1, 0, r);
            }).flatMap(identity());
    }

    /**
     * Creates and returns all possible combinations of the given elements.
     *
     * The order of the combinations in the stream is unspecified.
     *
     * @param <T> element type
     * @param items to combine
     * @return all possible combinations of the given elements
     */
    @SuppressWarnings("unchecked")
    public static <T> Stream<List<T>> of(final Collection<T> items) {
        return of((T[]) items.toArray());
    }

    private static <T> Stream<List<T>> combinationHelper(
            T[] arr, T[] data,
            int start, int end,
            int index, int r) {<FILL_FUNCTION_BODY>}

    private static <T> List<T> asList(T[] array, int newSize) {
        return Stream.of(array)
            .limit(newSize)
            .collect(Collectors.toList());
    }

}


        // Current combination is ready to be printed, print it
        if (index == r) {
            return Stream.of(asList(data, r));
        }

        // replace index with all possible elements. The condition
        // "end-i+1 >= r-index" makes sure that including one element
        // at index will make a combination with remaining elements
        // at remaining positions
        return IntStream.rangeClosed(start, end)
            .filter(i -> end - i + 1 >= r - index)
            .mapToObj(i -> {
                data[index] = arr[i];
                return combinationHelper(arr, data, i + 1, end, index + 1, r);
            }).flatMap(identity());
    
<no_super_class>