PsiJavaCodeReferenceElement (@NotNull PsiElement element, @NotNull PsiReferenceList referenceList) { while (element.getParent() != referenceList) { element = element.getParent(); if (element == null) return null; } return ObjectUtils.tryCast(element, PsiJavaCodeReferenceElement.class); }