I wrote this extension method (which compiles): public static IEnumerable<J> Flatten<T, J>(this IEnumerable&…