segments.add(additionalPath.segments.removeFirst());
additionalHead = (IntLine) additionalPath.segments.removeFirst(); segments.add(additionalHead); actualLength.add(additionalHead.getLength());
    public Point moveTailTo(TrainPath additionalPath) {	IntLine tail = (IntLine) additionalPath.segments.removeFirst();	IntLine head = getLastSegment();	Point oldHeadPoint = new Point (tail.x1, tail.y1);	if (tail.getDirection() == head.getDirection()) {	    head.append(tail);	} else {	    segments.add(tail);	}	/* add the rest of the path */	while (! additionalPath.segments.isEmpty()) {	    segments.add(additionalPath.segments.removeFirst());	}	double l = length;	int i = segments.size();	do {	    l -= ((IntLine) segments.get(i)).getLength();	    i--;	} while (l > 0 && i >= 0);	while (i > 0) {	    /* remaining segments are surplus to requirements */	    segments.removeFirst();	    i--;	};		if (l < 0) {	    IntLine seg = (IntLine) segments.getFirst();	    seg.setLengthFromTail(seg.getLength() + l);	}	return oldHeadPoint;    }