code: private void addTreeItem(
          CmsObject cms,
          CmsResource resource,
          CmsUUID parentId,
          boolean disabled,
          HierarchicalContainer container) {
  
          CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource);
          Item resourceItem = container.getItem(resource.getStructureId());
          if (resourceItem == null) {
              resourceItem = container.addItem(resource.getStructureId());
          }
  
          // use the root path as name in case of the root item
          String resName = parentId == null ? resource.getRootPath() : resource.getName();
          resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_RESOURCE_NAME).setValue(resName);
          resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_STATE).setValue(resource.getState());
  
          resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_INSIDE_PROJECT).setValue(
              Boolean.valueOf(resUtil.isInsideProject()));
          resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_RELEASED_NOT_EXPIRED).setValue(
              Boolean.valueOf(resUtil.isReleasedAndNotExpired()));
          String iconHTML = CmsResourceIcon.getTreeCaptionHTML(resName, resUtil, null, false);
  
          resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_TREE_CAPTION).setValue(iconHTML);
          if (disabled) {
              resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_DISABLED).setValue(Boolean.TRUE);
          }
          if (parentId != null) {
              container.setChildrenAllowed(parentId, true);
              container.setParent(resource.getStructureId(), parentId);
          }
      }
docs: Adds an item to the folder tree.<p>
  
  @param cms the cms context
  @param resource the folder resource
  @param parentId the parent folder id
  @param disabled in case the item is disabled, used for non visible parent folders
  @param container the data container