/**
  * Render item with all of its children.
  *
  * This renders the li tag to fit into the parent ul as well as its
  * own nested ul tag if this menu item has children
  *
  * @param integer $depth The depth each child should render
  * @return string
  */
 protected function _renderItem(ioMenuItem $item, $depth = null)
 {
     // if we don't have access or this item is marked to not be shown
     if (!$item->shouldBeRendered()) {
         return;
     }
     // explode the class string into an array of classes
     $class = $item->getAttribute('class') ? explode(' ', $item->getAttribute('class')) : array();
     if ($item->isCurrent()) {
         $class[] = 'current';
     } elseif ($item->isCurrentAncestor($depth)) {
         $class[] = 'current_ancestor';
     }
     if ($item->actsLikeFirst()) {
         $class[] = 'first';
     }
     if ($item->actsLikeLast()) {
         $class[] = 'last';
     }
     // retrieve the attributes and put the final class string back on it
     $attributes = $item->getAttributes();
     if (count($class) > 0) {
         $attributes['class'] = implode(' ', $class);
     }
     // opening li tag
     $html = $this->_format($item->getLevel(), '<li' . _tag_options($attributes) . '>', 'li');
     // render the text/link inside the li tag
     $html .= $this->_format($item->getLevel(), $item->getRoute() ? $item->renderLink() : $item->renderLabel(), 'link');
     // renders the embedded ul if there are visible children
     $html .= $this->_render($item, $depth, true);
     // closing li tag
     $html .= $this->_format($item->getLevel(), '</li>', 'li');
     return $html;
 }