Fix for #22232

Fix for #22232 preventing RuntimeError Maximum Recursion Depth Exceeded when a template extends itself.
https://code.djangoproject.com/ticket/22232
Since you're referring to `context.render_context[EXTENDS_HISTORY_CONTEXT_KEY]` in a couple of places here it might be a good idea to store it in a local variable. e.g.

```python
extends_history = context.render_context.setdefault(EXTENDS_HISTORY_CONTEXT_KEY, [])
parent_name = compiled_parent.name
if parent_name in extends_history:
    raise TemplateRecursionError('Circular template extension error in %s' % extends_history)
else:
    extends_history.append(parent_name)
```