private static @NotNull <T> List<SmartPsiElementPointer<?>> calcPsiTargets(@NotNull Project project,
                                                                             @NotNull Collection<? extends T> targets,
                                                                             @NotNull NotNullFunction<? super T, ? extends Collection<? extends PsiElement>> converter) {
    SmartPointerManager manager = SmartPointerManager.getInstance(project);
    Set<PsiElement> elements = new HashSet<>();
    final List<SmartPsiElementPointer<?>> list = new ArrayList<>(targets.size());
    for (final T target : targets) {
      for (final PsiElement psiElement : converter.fun(target)) {
        if (psiElement == null) {
          throw new IllegalArgumentException(converter + " returned null element");
        }

        if (elements.add(psiElement) && psiElement.isValid()) {
          list.add(manager.createSmartPsiElementPointer(psiElement));
        }
      }
    }
    return list;
  }
private static @NotNull <T> List<SmartPsiElementPointer<?>> calcPsiTargets(@NotNull Project project,
                                                                             @NotNull Collection<? extends T> targets,
                                                                             @NotNull NotNullFunction<? super T, ? extends Collection<? extends PsiElement>> converter)