PsiJavaCodeReferenceElement (@NotNull PsiJavaCodeReferenceElement ref) { PsiJavaCodeReferenceElement element = ref; while (true) { PsiElement parent = element.getParent(); if (parent instanceof PsiJavaCodeReferenceElement) { element = (PsiJavaCodeReferenceElement)parent; } else { break; } } return element; }