List<PsiType> (@NotNull PsiType from, @NotNull PsiType to) { Set<PsiType> types = new LinkedHashSet<>(); Queue<PsiType> queue = new ArrayDeque<>(); queue.offer(from); while (!queue.isEmpty()) { PsiType type = queue.poll(); if (to.isAssignableFrom(type)) { types.add(type); Arrays.stream(type.getSuperTypes()).forEach(queue::offer); } } List<PsiType> result = new ArrayList<>(types); Collections.reverse(result); return result; }