private static @Nullable Class<?> findServiceInterface(@NotNull Class<?> clazz, @NotNull String serviceInterface) {
    for (Class<?> anInterface : clazz.getInterfaces()) {
      if (serviceInterface.equals(anInterface.getName())) {
        return anInterface;
      }
    }

    Class<?> superclass = clazz.getSuperclass();
    if (superclass != null) {
      if (serviceInterface.equals(superclass.getName())) {
        return superclass;
      }

      return findServiceInterface(superclass, serviceInterface);
    }

    return null;
  }
private static @Nullable Class<?> findServiceInterface(@NotNull Class<?> clazz, @NotNull String serviceInterface)