docs: protected CmsContainerPageBean cleanupContainersContainers(CmsObject cms, CmsContainerPageBean cntPage) {
  
          // get the used containers first
          Map<String, CmsContainerBean> currentContainers = cntPage.getContainers();
          List<CmsContainerBean> containers = new ArrayList<CmsContainerBean>();
          for (String cntName : cntPage.getNames()) {
              CmsContainerBean container = currentContainers.get(cntName);
              if (!container.getElements().isEmpty()) {
                  containers.add(container);
              }
          }
  
          // now get the unused containers
          CmsContainerPageBean currentContainerPage = getContainerPage(cms);
          if (currentContainerPage != null) {
              for (String cntName : currentContainerPage.getNames()) {
                  if (!currentContainers.containsKey(cntName)) {
                      CmsContainerBean container = currentContainerPage.getContainers().get(cntName);
                      if (!container.getElements().isEmpty()) {
                          containers.add(container);
                      }
                  }
              }
          }
  
          // check if any nested containers have lost their parent element
  
          // first collect all present elements
          Map<String, CmsContainerElementBean> pageElements = new HashMap<String, CmsContainerElementBean>();
          Map<String, String> parentContainers = new HashMap<String, String>();
          for (CmsContainerBean container : containers) {
              for (CmsContainerElementBean element : container.getElements()) {
                  try {
                      element.initResource(cms);
  
                      if (!CmsModelGroupHelper.isModelGroupResource(element.getResource())) {
                          pageElements.put(element.getInstanceId(), element);
                          parentContainers.put(element.getInstanceId(), container.getName());
                      }
                  } catch (CmsException e) {
                      LOG.warn(e.getLocalizedMessage(), e);
                  }
              }
          }
          Iterator<CmsContainerBean> cntIt = containers.iterator();
          while (cntIt.hasNext()) {
              CmsContainerBean container = cntIt.next();
              // check all unused nested containers if their parent element is still part of the page
              if (!currentContainers.containsKey(container.getName())
                  && (container.isNestedContainer() && !container.isRootContainer())) {
                  boolean remove = !pageElements.containsKey(container.getParentInstanceId())
                      || container.getElements().isEmpty();
                  if (!remove) {
                      // check if the parent element formatter is set to strictly render all nested containers
                      CmsContainerElementBean element = pageElements.get(container.getParentInstanceId());
                      String settingsKey = CmsFormatterConfig.getSettingsKeyForContainer(
                          parentContainers.get(element.getInstanceId()));
                      String formatterId = element.getIndividualSettings().get(settingsKey);
                      if (CmsUUID.isValidUUID(formatterId)) {
                          I_CmsFormatterBean formatterBean = OpenCms.getADEManager().getCachedFormatters(
                              false).getFormatters().get(new CmsUUID(formatterId));
                          remove = (formatterBean instanceof CmsFormatterBean)
                              && ((CmsFormatterBean)formatterBean).isStrictContainers();
                      }
                  }
                  if (remove) {
                      // remove the sub elements from the page list
                      for (CmsContainerElementBean element : container.getElements()) {
                          pageElements.remove(element.getInstanceId());
                      }
                      // remove the container
                      cntIt.remove();
                  }
              }
          }
  
          return new CmsContainerPageBean(containers);
      }