public static <K, V> Map<K, V> makeMutableMap(Map<K, V> map) {
    return switch (map) {
      case HashMap<K, V> m -> m;
      case TreeMap<K, V> m -> m;
      case NavigableMap<K, V> m -> new TreeMap<>(m);
      case SequencedMap<K, V> m -> new LinkedHashMap<>(m);
      case null -> map;
      default -> new HashMap<>(map);
    };
  }
Return a mutable copy of {@code map} or the original list if it is already mutable.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/MutableCollections.java