only iterate over the versions once and use `groupBy` to sort the dependencies into the version mapping