private static @Nullable PyClassLikeType getMostDerivedClassType(@NotNull List<@NotNull PyClassLikeType> classTypes,
                                                                   @NotNull TypeEvalContext context) {
    if (classTypes.isEmpty()) {
      return null;
    }
    try {
      return classTypes
        .stream()
        .max(
          (t1, t2) -> {
            if (Objects.equals(t1, t2)) {
              return 0;
            }
            else if (t1.getAncestorTypes(context).contains(t2)) {
              return 1;
            }
            else if (t2.getAncestorTypes(context).contains(t1)) {
              return -1;
            }
            else {
              throw new NotDerivedClassTypeException();
            }
          }
        )
        .orElse(null);
    }
    catch (NotDerivedClassTypeException ignored) {
      return null;
    }
  }
private static @Nullable PyClassLikeType getMostDerivedClassType(@NotNull List<@NotNull PyClassLikeType> classTypes,
                                                                   @NotNull TypeEvalContext context)