boolean (@NotNull CompositeElement classRef) { while (true) { ASTNode qualifier = classRef.findChildByRole(ChildRole.QUALIFIER); if (qualifier == null) return false; if (qualifier.getElementType() != JavaElementType.REFERENCE_EXPRESSION) return false; PsiElement refElement = ((PsiReference)qualifier).resolve(); if (refElement instanceof PsiPackage) return true; classRef = (CompositeElement)qualifier; } }