It could be refactorized into something like this:
```php
        $item = $this->buildSingleItem($itemConfig);
        if (!is_array($itemConfig)) {
            return $item;
        }

        if (!isset($item)) {
            reset($itemConfig);
            $item = new Item(key($itemConfig));
            $this->iterateBuildMenu($item, current($itemConfig));
        }

        if (isset($itemConfig['id']) && $this->manager->hasElement($itemConfig['id'])) {
            $item->setElement($this->manager->getElement($itemConfig['id']));
        }

        return $item;
```
And also you should extract ``buildSingleItem()`` method. Besides you could change ``array_key_exists('key', $array)`` to shorter ``isset($array['key'])``. ``array_key_exists()`` is also a bit tricky as it returns true when key exists but has a ``null`` value.