List<PyTargetExpression> (@NotNull PyClass cls) { List<PyTargetExpression> attrs = new ArrayList<>(); List<String> seenNames = new ArrayList<>(); for (PyTargetExpression expr : cls.getClassAttributes()) { seenNames.add(expr.getName()); } for (PyClass ancestor : cls.getAncestorClasses(null)) { for (PyTargetExpression expr : ancestor.getClassAttributes()) { if (!seenNames.contains(expr.getName())) { seenNames.add(expr.getName()); attrs.add(expr); } } } return attrs; }