code: public ResourceHandle getParent(String resourceType) {
          ResourceHandle result = getResource();
          while (result.isValid() && !result.isResourceType(resourceType)) {
              result = result.getParent();
          }
          if (!result.isValid()) {
              result = getParent(resourceType, getPath()); // implicit fallback to the path
          }
          return result;
      }
docs: Determine a typed parent resource.