Although this doesn't appear to be covered by any integral test, it looks like it is doing the right thing...provided that there is never a way that `piecewise_fold` could ever return something other than piecewise. But as this will likely be hard to track down should it ever occur, this should be written as (first draft)

```
...
def remove_x0_y0(expr, first=True):
  if first:
    p = piecewise_fold(expr)
  if isinstance(p, Piecewise):
    p = Piecewise(*[(remove_x0_y0(e, first=False), c) for e, c in p.args])
return p.as_independent(x0, y0, as_Add=True)[0]
```

But the problem with that is that you have to do the test every time. So perhaps this is better to leave in the main code as:

```
if tmpsol.has(Piecewise):
    tmpsol = piecewise_fold(tmpsol)
if isinstance(tmpsol, Piecewise):
    tmpsol = Piecewise(*[(e.as_independent(x0, y0, as_Add=True), c) for e, c in tmpsol.args])
else:
    tmpsol = tmpsol.as_independent(x0, y0, as_Add=True)
```