code: public static void addCalculatedModuleResources(
          List<CmsResource> result,
          final CmsObject cms,
          final List<CmsResource> moduleResources,
          final List<String> excludeResources)
      throws CmsException {
  
          for (CmsResource resource : moduleResources) {
  
              String sitePath = cms.getSitePath(resource);
  
              List<String> excludedSubResources = getExcludedForResource(sitePath, excludeResources);
  
              // check if resources have to be excluded
              if (excludedSubResources.isEmpty()) {
                  // no resource has to be excluded - add the whole resource
                  // (that is, also all resources in the folder, if the resource is a folder)
                  result.add(resource);
              } else {
                  // cannot add the complete resource (i.e., including the whole sub-tree)
                  if (CmsStringUtil.comparePaths(sitePath, excludedSubResources.get(0))) {
                      // the resource itself is excluded -> do not add it and check the next resource
                      continue;
                  }
                  // try to include sub-resources.
                  List<CmsResource> subResources = cms.readResources(sitePath, CmsResourceFilter.ALL, false);
                  addCalculatedModuleResources(result, cms, subResources, excludedSubResources);
              }
          }
  
      }
docs: Determines the resources that are:
  <ul>
  <li>accessible with the provided {@link CmsObject},</li>
  <li>part of the <code>moduleResources</code> (or in a folder of these resources) and</li>
  <li><em>not</em> contained in <code>excludedResources</code> (or a folder of these resources).</li>
  </ul>
  and adds the to <code>result</code>
  
  @param result the resource list, that gets extended by the calculated resources.
  @param cms the {@link CmsObject} used to read resources.
  @param moduleResources the resources to include.
  @param excludeResources the site paths of the resources to exclude.
  @throws CmsException thrown if reading resources fails.