public static IEnumerable <ITree <TSource> > ToTree <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TKey> parentKeySelector) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (keySelector == null) { throw new ArgumentNullException(nameof(keySelector)); } if (parentKeySelector == null) { throw new ArgumentNullException(nameof(parentKeySelector)); } return(TreeCollection.CreateTree(source, keySelector, parentKeySelector)); }