}
protected void encodeIcon(FacesContext context, UIComponent component) throws IOException {
TreeNodeState nodeState = getNodeState(context);
AbstractTreeNode treeNode = (AbstractTreeNode) component;
AbstractTree tree = treeNode.findTreeComponent();
if (nodeState.isLeaf()) {
String iconLeaf = (String) getFirstNonEmptyAttribute("iconLeaf", treeNode, tree);
encodeIconForNodeState(context, tree, treeNode, nodeState, iconLeaf);
} else {
String iconExpanded = (String) getFirstNonEmptyAttribute("iconExpanded", treeNode, tree);
String iconCollapsed = (String) getFirstNonEmptyAttribute("iconCollapsed", treeNode, tree);
if (Strings.isNullOrEmpty(iconCollapsed) && Strings.isNullOrEmpty(iconExpanded)) {
encodeIconForNodeState(context, tree, treeNode, nodeState, null);
} else {
SwitchType toggleType = TreeRendererBase.getToggleTypeOrDefault(treeNode.findTreeComponent());
if (toggleType == SwitchType.client || nodeState == TreeNodeState.collapsed) {
encodeIconForNodeState(context, tree, treeNode, TreeNodeState.collapsed, iconCollapsed);
}