A few lines of inline comments are appropriate here. Why are you doing this simplification, especially when the result you obtain may not be valid, e.g. (x**2)**y is not always x**(2*y) but that is what the logic of what you added will do. Match is also pretty slow. For something like this it might be better to explicitly test for what you are looking for:

```
if t.is_Pow:
    if t.base.is_Pow:
        ...
    elif (-t.base).is_Pow:
        ...
etc...
```

Also, do you only expect to get (possibly) a minus sign in front of the base? Could you get something like `(-2*x**z)**y`?