protected function insertResources(array $resources)
    {
        foreach ($resources as $resource) {
            if (null === $resource->getParent()) {
                $this->addResource($resource);
            } else {
                $parent = $resource->getParent()->getResourceId();
                $this->addResource($resource, $parent);
            }
        }

        return $this;
    }