protected function _resolveContainer(BaseContainerInterface $container)
    {
        $parent = null;

        while ($container instanceof ContainerAwareInterface) {
            $parent = $container->getContainer();

            if (!($parent instanceof BaseContainerInterface)) {
                break;
            }
            $container = $parent;
        }

        return $container;
    }