code: protected void addChildren(CmsTreeItem parent, List<CmsGalleryTreeEntry> children, List<String> selectedGalleries) {
  
          if (children != null) {
              for (CmsGalleryTreeEntry child : children) {
                  // set the category tree item and add to parent tree item
                  CmsTreeItem treeItem = createTreeItem(child, selectedGalleries, true);
                  if ((selectedGalleries != null) && selectedGalleries.contains(child.getPath())) {
                      parent.setOpen(true);
                      openParents(parent);
                  }
                  parent.addChild(treeItem);
                  addChildren(treeItem, child.getChildren(), selectedGalleries);
              }
          }
      }
docs: Adds children to the gallery tree and select the galleries.<p>
  
  @param parent the parent item
  @param children the list of children
  @param selectedGalleries the list of galleries to select