aggregate_max_prefix implementation

Aggregate intervals according to a prefix. Can be used to create an
"aggregate" tool!