private List<LookupElement> fillModelByRelevance(LookupElementListPresenter lookup,
                                                   Set<? extends LookupElement> items,
                                                   Iterable<? extends LookupElement> sortedElements,
                                                   @Nullable LookupElement relevantSelection) {
    Iterator<? extends LookupElement> byRelevance = sortedElements.iterator();

    final LinkedHashSet<LookupElement> model = new LinkedHashSet<>();

    addPrefixItems(model);
    addFrozenItems(items, model);
    if (model.size() < MAX_PREFERRED_COUNT) {
      addSomeItems(model, byRelevance, lastAdded -> model.size() >= MAX_PREFERRED_COUNT);
    }
    addCurrentlySelectedItemToTop(lookup, items, model);

    freezeTopItems(lookup, model);

    ensureItemAdded(items, model, byRelevance, lookup.getCurrentItem());
    ensureItemAdded(items, model, byRelevance, relevantSelection);
    ContainerUtil.addAll(model, byRelevance);

    return new ArrayList<>(model);
  }
private List<LookupElement> fillModelByRelevance(LookupElementListPresenter lookup,
                                                   Set<? extends LookupElement> items,
                                                   Iterable<? extends LookupElement> sortedElements,
                                                   @Nullable LookupElement relevantSelection)