protected void encodeIconForNodeState(
     FacesContext context,
     AbstractTree tree,
     AbstractTreeNode treeNode,
     TreeNodeState nodeState,
     String customIcon)
     throws IOException {
   if (Strings.isNullOrEmpty(customIcon)) {
     encodeDefaultIcon(
         context,
         treeNode,
         concatClasses(
             nodeState.getIconClass(),
             treeNode.getAttributes().get("iconClass"),
             tree.getAttributes().get("iconClass")));
   } else {
     encodeCustomIcon(
         context,
         treeNode,
         concatClasses(
             nodeState.getCustomIconClass(),
             treeNode.getAttributes().get("iconClass"),
             tree.getAttributes().get("iconClass")),
         customIcon);
   }
 }
  protected UIComponent getHandleLoadingFacetIfApplicable(UIComponent component) {
    AbstractTreeNode treeNode = (AbstractTreeNode) component;

    AbstractTree tree = treeNode.findTreeComponent();

    if (TreeRendererBase.getToggleTypeOrDefault(tree) != SwitchType.ajax) {
      return null;
    }

    UIComponent facet = treeNode.getFacet(HANDLE_LOADING_FACET_NAME);
    if (facet == null) {
      facet = tree.getFacet(HANDLE_LOADING_FACET_NAME);
    }

    if (facet != null && facet.isRendered()) {
      return facet;
    }

    return null;
  }