List<PyClassLikeType> (@NotNull TypeEvalContext context) { final List<PyClassLikeType> results = new ArrayList<>(); final Deque<PyClassLikeType> toProcess = new LinkedList<>(); final Set<PyClassLikeType> seen = new HashSet<>(); final Set<PyClassLikeType> visited = new HashSet<>(); final PyType thisType = context.getType(this); if (thisType instanceof PyClassLikeType) { toProcess.add((PyClassLikeType)thisType); } while (!toProcess.isEmpty()) { final PyClassLikeType currentType = toProcess.pollFirst(); if (!visited.add(currentType)) { continue; } for (PyClassLikeType superType : currentType.getSuperClassTypes(context)) { if (superType == null || !seen.contains(superType)) { results.add(superType); seen.add(superType); } if (superType != null && !visited.contains(superType)) { toProcess.addLast(superType); } } } return results; }