public function extract($name = null)
    {
        if ($name instanceof LibBaseTemplateObjectInterface) {
            $name = $name->getName();
        }

        if (is_null($name)) {
            return array_shift($this->_objects);
        } elseif (is_array($name)) {
            $container = clone $this;
            $container->setObjects(array());
            foreach ($name as $key) {
                if ($object = $this->extract($key)) {
                    $container[] = $object;
                }
            }

            return $container;
        } else {
            $object = null;

            if (isset($this->_objects[$name])) {
                $object = $this->_objects[$name];
                unset($this->_objects[$name]);
            }

            return $object;
        }
    }