private function innerResolve(DependencyNode $rootNode, ArrayObject $resolved, ArrayObject $seen)
    {
        $seen->append($rootNode);
        foreach ($rootNode->getDependencies() as $edge) {
            if (!$this->arrayObjectContains($edge, $resolved)) {
                if ($this->arrayObjectContains($edge, $seen)) {
                    throw new CircularDependencyException(
                        sprintf('Circular dependency detected: %s depends on %s', $rootNode->getName(), $edge->getName())
                    );
                }

                $this->innerResolve($edge, $resolved, $seen);
            }
        }

        $resolved->append($rootNode);
    }