New function 'traverseSegment'. Function 'toListSegment' is now implemented on terms of 'traverseSegment' and a phantomized version of difference lists.