code: public ResourceHandle getParent(String resourceType, String path) {
          ResourceResolver resolver = getResolver();
          Resource resource;
          while (((resource = resolver.getResource(path)) == null || !resource.isResourceType(resourceType))
                  && StringUtils.isNotBlank(path)) {
              int delimiter = path.lastIndexOf('/');
              if (delimiter >= 0) {
                  path = path.substring(0, delimiter);
              } else {
                  break;
              }
          }
          return ResourceHandle.use(resource);
      }
docs: Use path instead of resource (e.g. if resource is synthetic or non existing) to determine a typed parent.