docs: public CmsFolder readAncestor(CmsRequestContext context, CmsResource resource, CmsResourceFilter filter)
      throws CmsException {
  
          // get the full folder path of the resource to start from
          String path = CmsResource.getFolderPath(resource.getRootPath());
          do {
              // check if the current folder matches the given filter
              if (existsResource(context, path, filter)) {
                  // folder matches, return it
                  return readFolder(context, path, filter);
              } else {
                  // folder does not match filter criteria, go up one folder
                  path = CmsResource.getParentFolder(path);
              }
  
              if (CmsStringUtil.isEmpty(path) || !path.startsWith(context.getSiteRoot())) {
                  // site root or root folder reached and no matching folder found
                  return null;
              }
          } while (true);
      }