Child of page with specific template

Hi everyone. I’m trying to create an If that comprehends a page with an specific template and all its childs. Now I’m achieving this behavior with the following code, but is not a good solution.

<?php if ($page->template() == 'edición' or $page->parent()->template() == 'edición'): ?>
    //code
<?php endif ?>

Anyone knows a better way to do this?

Thanks in advance.

You could probably achieve this with a filter rather than your if statement, but I’m not sure what pages your are trying to fetch here and in what context.