boolean (String name, PsiElement psiElement) { if (psiElement.getUserData(PyReplaceExpressionUtil.SELECTION_BREAKS_AST_NODE) != null) { final Pair<PsiElement,TextRange> data = psiElement.getUserData(PyReplaceExpressionUtil.SELECTION_BREAKS_AST_NODE); psiElement = data.first; } PsiElement context = PsiTreeUtil.getParentOfType(psiElement, PyFunction.class); if (context == null) { context = PsiTreeUtil.getParentOfType(psiElement, PyClass.class); } if (context == null) { context = psiElement.getContainingFile(); } return PyUtil.collectUsedNames(context).contains(name) || PyBuiltinCache.getInstance(psiElement).getByName(name) != null; }