code: protected CmsResource readSitemapEntryFolderIfPossible(CmsResource resource) {
  
          CmsObject cms = A_CmsUI.getCmsObject();
          try {
              if (resource.isFolder()) {
                  return resource;
              }
              CmsResource parent = cms.readParentFolder(resource.getStructureId());
              CmsResource defaultFile = cms.readDefaultFile(parent, CmsResourceFilter.IGNORE_EXPIRATION);
              if ((defaultFile != null) && defaultFile.equals(resource)) {
                  return parent;
              }
              return resource;
          } catch (CmsException e) {
              LOG.error(e.getLocalizedMessage(), e);
              return resource;
          }
      }
docs: If the given resource is the default file of a sitmeap entry folder, then returns that
  folder, else the original file.<p>
  
  @param resource a resource
  @return the resource or its parent folder