New group_by_latest_versions() function