Fixed #15053 -- Improved template extending algorithm.

The `else:` branch is redundant here, you can `raise TemplateDoesNotExist(name, tried=tried)` directly.