I'm not sure what sort of expressions might make it to here, but do you mean `if isinstance(expr, Piecewise)`? I'm wondering if this is going to do the right thing if expr is `x   + Piecewise(foo)`