public static IEnumerable <T> GetAllDataObjects <T>(this IBidirectionalGraph <Cluster <T>, ClusterEdge <T> > tree, Cluster <T> cluster) { if (tree.IsOutEdgesEmpty(cluster)) { return(cluster.DataObjects); } return(tree.OutEdges(cluster).Aggregate((IEnumerable <T>)cluster.DataObjects, (res, edge) => res.Concat(tree.GetAllDataObjects(edge.Target)))); }