PsiElement (PsiElement element, Function<FileReference, PsiElement> callback) { if (element instanceof PsiFile) { FileReference lastRef = new FileReferenceSet(element).getLastReference(); if (lastRef != null) { return callback.apply(lastRef); } } return null; }