code: private void removeNestedItemsFromTopLevel(ResourceMap publishRelatedResources) {
  
          Set<CmsResource> toDelete = Sets.newHashSet();
          for (CmsResource parent : publishRelatedResources.keySet()) {
              if (toDelete.contains(parent)) {
                  continue;
              }
              for (CmsResource child : publishRelatedResources.get(parent)) {
                  if (publishRelatedResources.containsKey(child)) {
                      toDelete.add(child);
                  }
              }
          }
          for (CmsResource delResource : toDelete) {
              publishRelatedResources.remove(delResource);
          }
      }
docs: Removes those resources as keys from the resource map which also occur as related resources under a different key.<p>
  
  @param publishRelatedResources the resource map from which to remove the duplicate items