Javadoc
Search seglist for a segment with endpoint (xend, yend).
The cell entry direction is dir, and if tail=1/0 we are
building the tail/head of a contour. The matching segment
is pointed to by seg and the updated segment list (with
the matched segment stripped) is returned by the function.