collapse_episode function

Group records no more than n days apart as episodes