Truly generic collection compaction functions, with the second one you can even provide a custom merge. By compaction I mean merging consecutive "identical" values into a single one.