TODO: get rid of the 'empty deque' case in [regularize], because [do_regularize] can't return an empty deque