private function searchBlock($blockName, Twig_Template $tpl)
{
// Current template might have parents, so we need to loop against
// them to find a matching block
do {
foreach ($tpl->getBlocks() as $name => $block) {
if ($name === $blockName) {
return $block;
}
}
} while (($tpl = $tpl->getParent([])) instanceof Twig_Template);
return null;
}