Group by invariant
Pattern matching proof-of-concept