code: Class getMethodMapClass(Method method) {
  
          Class origMapClass = method.getDeclaringClass();
          Class mapClass = origMapClass;
          while (mapClass != null && !isValidMapClass(mapClass)) {
              mapClass = mapClass.getDeclaringClass();
          }
          if (mapClass == null) {
              mapClass = origMapClass;
          }
          return mapClass;
      }
docs: further in the hierarchy.