code: private static CmsObject adjustSiteRootIfNecessary(final CmsObject cms, final CmsModule module)
      throws CmsException {
  
          CmsObject cmsClone;
          if ((null == module.getSite()) || cms.getRequestContext().getSiteRoot().equals(module.getSite())) {
              cmsClone = cms;
          } else {
              cmsClone = OpenCms.initCmsObject(cms);
              cmsClone.getRequestContext().setSiteRoot(module.getSite());
          }
  
          return cmsClone;
      }
docs: Adjusts the site root and returns a cloned CmsObject, iff the module has set an import site that differs
  from the site root of the CmsObject provided as argument. Otherwise returns the provided CmsObject unchanged.
  @param cms The original CmsObject.
  @param module The module where the import site is read from.
  @return The original CmsObject, or, if necessary, a clone with adjusted site root
  @throws CmsException see {@link OpenCms#initCmsObject(CmsObject)}