public static <T> List<T> flatten_stream(List<?> list, Class<T> elementType) {
        return list
                .stream()
                .flatMap(e -> e instanceof List ? flatten_stream(((List<?>) e), elementType).stream() : Stream.of(e))
                .map(e -> (T) e)
                .collect(toList());
    }
<b>(**) Flatten a nested list structure</b>
<p>
Transform a list, possibly holding lists as elements into a 'flat' list by replacing each list with its elements (recursively).
</p>
java8/src/main/java/com/shekhargulati/ninetynine_problems/_01_lists/P07.java