The structure of piecewise monotonic transformations