List<PsiClass> (PsiClass subClass, PsiClass superClass) { Map<PsiClass, PsiClass> inheritanceMap = new HashMap<>(); Queue<PsiClass> workQueue = new ArrayDeque<>(); workQueue.add(subClass); while (!workQueue.isEmpty()) { PsiClass cls = workQueue.poll(); for (PsiClass sup : StreamEx.of(cls.getInterfaces()).prepend(cls.getSuperClass()).nonNull()) { if (!inheritanceMap.containsKey(sup)) { inheritanceMap.put(sup, cls); workQueue.offer(sup); if (sup == superClass) { return StreamEx.iterate(superClass, c -> c != subClass, inheritanceMap::get).toList(); } } } } return Collections.emptyList(); }