public static <T> List<T> makeMutable(List<T> list) {
    return switch (list) {
      case ArrayList<T> l -> l;
      case LinkedList<T> l -> l;
      case AbstractSequentialList<T> l -> new LinkedList<>(l);
      case null -> list;
      default -> new ArrayList<>(list);
    };
  }
Return a mutable copy of {@code list} or the original list if it is already mutable.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/MutableCollections.java