code: private ResourceMap computeReachability(ResourceMap relatedResources) {
  
          ResourceMap result = new ResourceMap();
          for (CmsResource resource : relatedResources.keySet()) {
              result.get(resource).add(resource);
              result.get(resource).addAll(relatedResources.get(resource));
          }
          int oldSize, newSize;
          do {
              ResourceMap newReachableResources = new ResourceMap();
              oldSize = result.totalSize();
              for (CmsResource source : result.keySet()) {
                  for (CmsResource target : result.get(source)) {
                      // need to check if the key is present, otherwise we may get a ConcurrentModificationException
                      if (result.containsKey(target)) {
                          newReachableResources.get(source).addAll(result.get(target));
                      }
                  }
              }
              newSize = newReachableResources.totalSize();
              result = newReachableResources;
          } while (oldSize < newSize);
          return result;
      }
docs: Computes the "reachability map", given the map of direct relations between resources.<p>
  
  @param relatedResources a map containing the direct relations between resources
  @return a map from resources to the sets of resources which are reachable via relations