List<PsiNamedElement> () { // extract whatever names are defined in "for" components List<PyComprehensionForComponent> fors = getForComponents(); PyExpression[] for_targets = new PyExpression[fors.size()]; int i = 0; for (PyComprehensionForComponent for_comp : fors) { for_targets[i] = for_comp.getIteratorVariable(); i += 1; } final List<PyExpression> expressions = PyUtil.flattenedParensAndStars(for_targets); final List<PsiNamedElement> results = new ArrayList<>(); for (PyExpression expression : expressions) { if (expression instanceof PsiNamedElement) { results.add((PsiNamedElement)expression); } } return results; }