private static @NotNull <K, V> MultiMap<K, V> createMultiMap(boolean identityKeys) {
    return new MultiMap<>(identityKeys ? new Reference2ObjectOpenHashMap<>() : CollectionFactory.createSmallMemoryFootprintMap()) {
      @Override
      public boolean remove(K key, V value) {
        List<V> elements = (List<V>)get(key);
        int i = ContainerUtil.indexOfIdentity(elements, value);
        if (i >= 0) {
          elements.remove(i);
          if (elements.isEmpty()) {
            remove(key);
          }
          return true;
        }
        return false;
      }
    };
  }
private static @NotNull <K, V> MultiMap<K, V> createMultiMap(boolean identityKeys)