private static boolean isSelfInheritor(UClass uClass, List<? super UClass> visited) {
    if (visited.contains(uClass)) return true;
    visited.add(uClass);
    if (uClass.getUastSuperTypes().stream()
      .map(t -> PsiUtil.resolveClassInClassTypeOnly(t.getType()))
      .map(c -> UastContextKt.toUElement(c, UClass.class))
      .filter(Objects::nonNull)
      .anyMatch(c -> isSelfInheritor(c, visited))) {
      return true;
    }

    visited.remove(uClass);
    return false;
  }
private static boolean isSelfInheritor(UClass uClass, List<? super UClass> visited)