code: public void addTreeItem(CmsObject cms, CmsResource resource, CmsUUID parentId) {
  
          List<Container.Filter> filters = Lists.newArrayList(getContainerFilters());
  
          // getItem only finds an existing item if it isn't filtered out by the container
          // filters, so we temporarily remove the filters to access the complete data set
          removeAllContainerFilters();
          try {
              Item resourceItem = getItem(resource.getStructureId());
              if (resourceItem == null) {
                  resourceItem = addItem(resource.getStructureId());
              }
              fillProperties(cms, resourceItem, resource, parentId);
              if (resource.isFile()) {
                  setChildrenAllowed(resource.getStructureId(), false);
              }
              if (parentId != null) {
                  setParent(resource.getStructureId(), parentId);
              }
          } finally {
              for (Container.Filter filter : filters) {
                  addContainerFilter(filter);
              }
          }
      }
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