// ReSharper disable once CheckNamespace namespace System.Linq; public static class Enumerable { public static IEnumerable> GroupKeys( this IEnumerable> source, Func condition ) where TKey : notnull { return source.SelectMany(dict => dict.Where(pair => condition(pair.Value)).Select(pair => pair.Key)).GroupBy(x => x); } }