Moving the route grouping code out of the phi-estimation repository into this shared library.