class MostlySingularMultiMap<K, V> {
  private final Object2ObjectOpenHashMap<K, Object> map;

  public MostlySingularMultiMap(Map<K, List<V>> contents) {
    map = new Object2ObjectOpenHashMap<>(contents.size());
    for (Map.Entry<K, List<V>> entry : contents.entrySet()) {
      List<V> value = entry.getValue();
      map.put(entry.getKey(), value.size() == 1 ? value.get(0) : value.toArray());
    }
    map.trim();
  }

  @Nullable
  public List<V> getList(K key) {<FILL_FUNCTION_BODY>}


}

    Object o = map.get(key);
    //noinspection unchecked
    return o == null ? null :
           o instanceof Object[] ? Arrays.asList((V[]) o) :
           Collections.singletonList((V) o);
  
<no_super_class>