rollups2<T, K1, K2, R> function
Groups values by key1 and key2, reduces each leaf group with reduce,
and returns nested entry lists.
Implementation
List<(K1, List<(K2, R)>)> rollups2<T, K1, K2, R>(
Iterable<T> values,
R Function(List<T> group) reduce,
K1 Function(T value) key1,
K2 Function(T value) key2,
) {
final outer = group<T, K1>(values, key1);
return <(K1, List<(K2, R)>)>[
for (final e in outer.entries)
(e.key, rollups<T, K2, R>(e.value, reduce, key2)),
];
}