boolean (@NotNull PsiElement element) { final PyComprehensionElement comprehensionExpr = PsiTreeUtil.getParentOfType(element, PyComprehensionElement.class); if (comprehensionExpr == null) return false; return ContainerUtil.exists(comprehensionExpr.getForComponents(), it -> PsiTreeUtil.isAncestor(it.getIteratorVariable(), element, false)); }