boolean (PsiElement refElement) { PyStatement parentStatement = PsiTreeUtil.getParentOfType(refElement, PyStatement.class); if (parentStatement instanceof PyGlobalStatement || parentStatement instanceof PyNonlocalStatement || parentStatement instanceof PyImportStatementBase) { return false; } return PsiTreeUtil.getParentOfType(refElement, PyPlainStringElement.class, false, PyStatement.class) == null; }