protected function reduceItem (MenuItem $item)
    {
        $reduced = ['name' => $item->getTitle()];

        // Has children.
        if (count($item->getChildren()) > 0) {
            $reduced['sub_button'] = [];
            foreach ($item->getChildren() as $childItem) {
                $reduced['sub_button'][] = $this->reduceItem($childItem);
            }
        } // No children.
        else {
            $reduced['type'] = $item->getType();
            $reduced[$item->getType() === MenuItem::URL ? 'url' : 'key'] = $item->getKey();
        }

        return $reduced;
    }