Split into groupBy and groupByEquivRelation.

Instead of using an ugly compile-time flag parameter.