code: protected void paintCustomItem(final WTree tree, final WTree.ExpandMode mode, final TreeItemModel model, final TreeItemIdNode node,
  			final XmlStringBuilder xml, final Set<String> selectedRows, final Set<String> expandedRows) {
  
  		String itemId = node.getItemId();
  		List<Integer> rowIndex = tree.getRowIndexForCustomItemId(itemId);
  
  		boolean selected = selectedRows.remove(itemId);
  
  		boolean expandable = node.hasChildren();
  		boolean expanded = expandedRows.remove(itemId);
  
  		TreeItemImage image = model.getItemImage(rowIndex);
  		String url = null;
  		if (image != null) {
  			url = tree.getItemImageUrl(image, itemId);
  		}
  
  		xml.appendTagOpen("ui:treeitem");
  		xml.appendAttribute("id", tree.getItemIdPrefix() + itemId);
  		xml.appendAttribute("label", model.getItemLabel(rowIndex));
  		xml.appendOptionalUrlAttribute("imageUrl", url);
  		xml.appendOptionalAttribute("selected", selected, "true");
  		xml.appendOptionalAttribute("expandable", expandable, "true");
  		xml.appendOptionalAttribute("open", expandable && expanded, "true");
  		xml.appendClose();
  
  		// Paint child items
  		if (expandable && (mode == WTree.ExpandMode.CLIENT || expanded)) {
  			for (TreeItemIdNode childNode : node.getChildren()) {
  				paintCustomItem(tree, mode, model, childNode, xml, selectedRows, expandedRows);
  			}
  		}
  
  		xml.appendEndTag("ui:treeitem");
  
  	}
docs: Iterate of over the nodes to render the custom layout of the tree items.
  
  @param tree the WTree to render
  @param mode the expand mode
  @param model the tree model
  @param node the current node in the custom tree layout
  @param xml the XML string builder
  @param selectedRows the set of selected rows
  @param expandedRows the set of expanded rows