code: private static Boolean ancestorOrIHasParam(final Resource resource, String uriParamName) {
          Resource ancestor = resource;
  
          while (ancestor != null) {
              if (ancestor.getUriParameters().containsKey(uriParamName)) {
                  return true;
              }
              ancestor = ancestor.getParentResource();
          }
  
          return false;
      }
docs: Check if the given resource or its ancestor have the uri param of given name.
  
  @param resource     The resource on which to check.
  @param uriParamName Name of the uri Param we are looking for.
  @return <code>true</code> if this or its ancestor resource have the param of given name already define.