New utility function `group-by'