if (tail.getDirection() == head.getDirection()) {
int tailDir = tail.getDirection(); if (tailDir == 0 || (tailDir == head.getDirection())) { System.out.println("prepending " + tail + " to " + head);
    public void prepend(TrainPath additionalPath) {	int l = additionalPath.length;	IntLine tail = (IntLine) additionalPath.segments.removeLast();	IntLine head = getFirstSegment();	if (tail.getDirection() == head.getDirection()) {	    head.prepend(tail);	} else {	    segments.addFirst(tail);	}	/* add the rest of the path */	while (! additionalPath.segments.isEmpty()) {	    segments.addFirst(additionalPath.segments.removeLast());	}	length += l;    }