public function locateBestTemplate($name)
    {
        $templates = $this->getTemplates($name);

        foreach ($templates as $template) {
            if (false !== $template = $this->loader->findTemplate($template, false)) {
                return $template;
            }
        }

        throw new \Twig_Error_Loader(sprintf("Template \"%s\" not found. Tried the following:\n%s", $name, implode("\n", $templates)));
    }