docs: private void fragmentizeLayout(UserView view, FragmentDefinition fragment) {
          // if fragment not bound to user or layout empty due to error, return
          if (view.getUserId() == -1 || view.getLayout() == null) {
              return;
          }
  
          // Choose what types of content to apply from the fragment
          Pattern contentPattern = STANDARD_PATTERN; // default
          boolean allowExpandedContent =
                  Boolean.parseBoolean(
                          PropertiesManager.getProperty(PROPERTY_ALLOW_EXPANDED_CONTENT));
          if (allowExpandedContent) {
              contentPattern = EXPANDED_PATTERN;
          }
  
          // remove all non-regular or hidden top level folders
          // skip root folder that is only child of top level layout element
          Element layout = view.getLayout().getDocumentElement();
          Element root = (Element) layout.getFirstChild();
          NodeList children = root.getChildNodes();
  
          // process the children backwards since as we delete some the indices
          // shift around
          for (int i = children.getLength() - 1; i >= 0; i--) {
              Node node = children.item(i);
              if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("folder")) {
                  Element folder = (Element) node;
  
                  // strip out folder types 'header', 'footer' and regular,
                  // hidden folder "User Preferences" since users have their own
                  boolean isApplicable =
                          contentPattern.matcher(folder.getAttribute("type")).matches();
                  if (!isApplicable || folder.getAttribute("hidden").equals("true")) {
                      try {
                          root.removeChild(folder);
                      } catch (Exception e) {
                          throw new RuntimeException(
                                  "Anomaly occurred while stripping out "
                                          + " portions of layout for fragment '"
                                          + fragment.getName()
                                          + "'. The fragment will not be available for "
                                          + "inclusion into user layouts.",
                                  e);
                      }
                  }
              }
          }
          // now re-lable all remaining nodes below root to have a safe system
          // wide id.
  
          setIdsAndAttribs(
                  layout,
                  layout.getAttribute(Constants.ATT_ID),
                  "" + fragment.getId(),
                  "" + fragment.getPrecedence());
      }