@NotNull
  private static LoopReduceResult reduceInLoop(@NotNull PsiType selectorType,
                                               @NotNull PsiElement context,
                                               @NotNull Set<? extends PatternDescription> patterns,
                                               @NotNull BiPredicate<Set<? extends PatternDescription>, PsiType> stopAt,
                                               @NotNull ReduceCache cache, boolean tryToExpand) {
    boolean changed = false;
    int currentIteration = 0;
    Set<? extends PatternDescription> currentPatterns = new HashSet<>(patterns);
    boolean tryToExpandNext = tryToExpand;
    while (currentIteration < MAX_ITERATION_COVERAGE) {
      currentIteration++;
      if (stopAt.test(currentPatterns, selectorType)) {
        return new LoopReduceResult(currentPatterns, true, true);
      }
      ReduceResult reduceResult = reduce(selectorType, context, currentPatterns, cache);
      if (tryToExpandNext && !reduceResult.changed() && reduceResult.patterns().size() > 1) {
        reduceResult = unwrapSealedTypes(reduceResult.patterns(), cache);
        tryToExpandNext = false;
      }
      changed |= reduceResult.changed();
      currentPatterns = reduceResult.patterns();
      if (!reduceResult.changed()) {
        return new LoopReduceResult(currentPatterns, changed, false);
      }
    }
    LOG.error("The number of iteration is exceeded, length of set patterns: " + patterns.size() +
              "max length deconstruction: " + patterns.stream()
                .filter(t -> t instanceof PatternDeconstructionDescription)
                .map(t -> ((PatternDeconstructionDescription)t).list.size())
                .max(Comparator.naturalOrder())
    );
    return new LoopReduceResult(currentPatterns, changed, false);
  }
@NotNull
  private static LoopReduceResult reduceInLoop(@NotNull PsiType selectorType,
                                               @NotNull PsiElement context,
                                               @NotNull Set<? extends PatternDescription> patterns,
                                               @NotNull BiPredicate<Set<? extends PatternDescription>, PsiType> stopAt,
                                               @NotNull ReduceCache cache, boolean tryToExpand)