Collection<PsiReference> (Collection<? extends PsiReference> refs, PsiElement element) { Map<GroovyFile, String> aliases = new HashMap<>(); ArrayList<PsiReference> result = new ArrayList<>(); for (PsiReference ref : refs) { final PsiElement e = ref.getElement(); if (skipReference(element, aliases, e)) continue; result.add(ref); } return result; }