boolean (@NotNull PyComprehensionElement comprehensionElement, @NotNull String variableName) { for (PyComprehensionForComponent forComponent : comprehensionElement.getForComponents()) { final PyExpression iteratorVariable = forComponent.getIteratorVariable(); if (iteratorVariable instanceof PyTupleExpression) { for (PyExpression variable : (PyTupleExpression)iteratorVariable) { if (variable instanceof PyTargetExpression && variableName.equals(variable.getName())) { return true; } } } else if (iteratorVariable instanceof PyTargetExpression && variableName.equals(iteratorVariable.getName())) { return true; } } return false; }