src/Menu/Services/MenuItemBuilder.php
private function attachChildren($items, $parent = null)
    {
        foreach ($items as $item) {
            /** @var $parent MenuItem */
            $parent = $parent->addChild($item->content->title)
                ->setExtra('patterns', $this->extractPattern($item))
                ->setUri($item->url);

            return $this->attachChildren($item->children, $parent);
        }
    }
private function attachChildren($items, $parent = null)
    {
        foreach ($items as $item) {
            /** @var $parent MenuItem */
            $parent = $parent->addChild($item->content->title)
                ->setExtra('patterns', $this->extractPattern($item))
                ->setUri($item->url);

            return $this->attachChildren($item->children, $parent);
        }
    }
@param $items
@param $parent

@return array