List<SemElement> ( MultiMap<SemKey<?>, BiFunction<? super PsiElement, ? super ProcessingContext, ? extends Collection<? extends SemElement>>> producers, SemKey<?> key, PsiElement psi, ProcessingContext processingContext ) { List<SemElement> result = null; Collection<BiFunction<? super PsiElement, ? super ProcessingContext, ? extends Collection<? extends SemElement>>> functions = producers.get(key); if (!functions.isEmpty()) { for (var producer : functions) { Collection<? extends SemElement> elements = producer.apply(psi, processingContext); if (elements != null && !elements.isEmpty()) { if (result == null) result = new SmartList<>(); ContainerUtil.addAllNotNull(result, elements); } } } return result == null || result.isEmpty() ? emptyList() : result; }