PsiElement (@NotNull Collection<? extends PsiReference> refs) { PsiElement firstElement = null; for (PsiReference reference : refs) { final PsiElement element = reference.getElement(); if (!(element instanceof PsiReferenceExpression)) continue; if (firstElement == null || firstElement.getTextRange().getStartOffset() > element.getTextRange().getStartOffset()) { firstElement = element; } } return firstElement; }