code: private void addChildren(
          CmsTreeItem parent,
          List<CmsCategoryTreeEntry> children,
          Collection<String> selectedCategories) {
  
          if (children != null) {
              for (CmsCategoryTreeEntry child : children) {
                  // set the category tree item and add to parent tree item
                  CmsTreeItem treeItem;
                  boolean isPartofPath = false;
                  Iterator<String> it = selectedCategories.iterator();
                  while (it.hasNext()) {
                      String path = it.next();
                      if (path.contains(child.getPath())) {
                          isPartofPath = true;
                      }
                  }
                  if (isPartofPath) {
                      m_singleSidePath = child.getSitePath();
                      m_valuesSet++;
                      if (m_selectParent || !hasSelectedChildren(child.getChildren(), selectedCategories)) {
                          m_allSidePath.add(child.getSitePath());
                          treeItem = buildTreeItem(child, selectedCategories, false);
                      } else {
                          treeItem = buildTreeItem(child, selectedCategories, true);
                      }
                      addChildren(treeItem, child.getChildren(), selectedCategories);
                      parent.addChild(treeItem);
                  }
  
              }
          }
      }
docs: Adds children item to the category tree and select the categories.<p>
  
  @param parent the parent item
  @param children the list of children
  @param selectedCategories the list of categories to select