private static FoundItemDescriptor<Object> element2presentation(FoundItemDescriptor<Object> elementDescriptor,
                                                           Function<? super PsiElement, ? extends TargetPresentation> psiPresentationCalculator,
                                                           @Nullable SearchEverywherePresentationProvider<Object> rendererPresentationProvider) {
    if (elementDescriptor.getItem() instanceof PsiItemWithSimilarity<?> itemWithSimilarity) {
      TargetPresentation presentation = calcPresentation(itemWithSimilarity.getValue(), psiPresentationCalculator, rendererPresentationProvider);
      PsiItemWithSimilarity<?> newItemWithSimilarity = new PsiItemWithSimilarity<>(itemWithSimilarity.getValue(), itemWithSimilarity.getSimilarityScore());
      return new FoundItemDescriptor<>(new ItemWithPresentation<>(newItemWithSimilarity, presentation), elementDescriptor.getWeight());
    }

    TargetPresentation presentation = calcPresentation(elementDescriptor.getItem(), psiPresentationCalculator, rendererPresentationProvider);

    if (elementDescriptor.getItem() instanceof PsiElement psi) {
      return new FoundItemDescriptor<>(new PsiItemWithPresentation(psi, presentation), elementDescriptor.getWeight());
    }

    if (elementDescriptor.getItem() instanceof PsiElementNavigationItem psiElementNavigationItem) {
      var realElement = psiElementNavigationItem.getTargetElement();
      return new FoundItemDescriptor<>(new PsiItemWithPresentation(realElement, presentation), elementDescriptor.getWeight());
    }

    return new FoundItemDescriptor<>(new ItemWithPresentation<>(elementDescriptor.getItem(), presentation), elementDescriptor.getWeight());
  }
private static FoundItemDescriptor<Object> element2presentation(FoundItemDescriptor<Object> elementDescriptor,
                                                           Function<? super PsiElement, ? extends TargetPresentation> psiPresentationCalculator,
                                                           @Nullable SearchEverywherePresentationProvider<Object> rendererPresentationProvider)