docs: public static Type getGenericInterfaceType(Object instance, Class<?> iface, int position) {
      Class<?> type = instance.getClass();
      while (type != Object.class) {
        for (Type genericType : type.getGenericInterfaces()) {
          if (genericType instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) genericType;
            if (parameterizedType.getRawType() == iface) {
              return parameterizedType.getActualTypeArguments()[position];
            }
          }
        }
        type = type.getSuperclass();
      }
      return null;
    }