private static void fillMapFromGroup(@Nullable final GeoItem item, final Map<Integer, GeoPrimitive> map) {
        map.clear();
        if (item == null) {
            return;
        }
        GeoGroup.forAllPrimitives(item, p -> {
            //create unique index. Use hashCode as base so similar objects get similar indexes very often
            int idx = Objects.hashCode(p);
            while (map.containsKey(idx)) {
                idx++;
            }
            map.put(idx, p);
        });
    }
Replaces a set of items (identified by keysToReplace) with the given items. Prevents unnecessary remove+put for same key
main/src/main/java/cgeo/geocaching/unifiedmap/geoitemlayer/GeoItemLayer.java