boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!LanguageLevel.forElement(file).isPython2()) { final PyForStatement forLoop = findForStatementAtCaret(editor, file); if (forLoop != null) { final PyTargetExpression forTarget = findSingleForLoopTarget(forLoop); final PyReferenceExpression yieldValue = findSingleYieldValue(forLoop); if (forTarget != null && yieldValue != null) { final String targetName = forTarget.getName(); if (targetName != null && targetName.equals(yieldValue.getName())) { return true; } } } } return false; }