I believe that `piecewise_fold` already has a quick exit so you can remove the `if`.