code: public static Optional<Method> findMethod(Class type, String name, Class... argumentTypes) {
          Class currentType = type;
          while (currentType != null) {
              Method[] methods = currentType.isInterface() ? currentType.getMethods() : currentType.getDeclaredMethods();
              for (Method method : methods) {
                  if (name.equals(method.getName()) && Arrays.equals(argumentTypes, method.getParameterTypes())) {
                      return Optional.of(method);
                  }
              }
              currentType = currentType.getSuperclass();
          }
          return Optional.empty();
      }
docs: Finds a method on the given type for the given name.
  
  @param type          The type
  @param name          The name
  @param argumentTypes The argument types
  @return An {@link Optional} contains the method or empty