@Contract(pure = true)
  public static Int2ObjectMap<DFAType> mergeForCaching(@NotNull Int2ObjectMap<DFAType> cached,
                                                       @Nullable TypeDfaState candidate) {
    if (candidate == null || candidate.getRawVarTypes().isEmpty()) {
      return cached;
    }

    List<Int2ObjectMap.Entry<DFAType>> newTypes = new SmartList<>();
    for (Int2ObjectMap.Entry<DFAType> candidateEntry : candidate.getRawVarTypes().int2ObjectEntrySet()) {
      int index = candidateEntry.getIntKey();
      if (candidate.isProhibited(index) || (cached.containsKey(index) && checkDfaStatesConsistency(cached, candidateEntry))) {
        continue;
      }
      newTypes.add(candidateEntry);
    }
    if (newTypes.isEmpty()) {
      return cached;
    }
    Int2ObjectMap<DFAType> newState = new Int2ObjectOpenHashMap<>(cached.size() + newTypes.size());
    newState.putAll(cached);
    for (var entry : newTypes) {
      newState.put(entry.getIntKey(), entry.getValue());
    }
    return newState;
  }
@Contract(pure = true)
  public static Int2ObjectMap<DFAType> mergeForCaching(@NotNull Int2ObjectMap<DFAType> cached,
                                                       @Nullable TypeDfaState candidate)