private List<TripStructureUtils.Trip> getDriverTrip(
      final JointTrip toRemove, final Plan driverPlan) {
    final TripStructureUtils.Trip driverTrip =
        getTripWithLeg(driverPlan, toRemove.getDriverLegs().get(0), stagesWithJointTypes);
    assert driverTrip.getTripElements().containsAll(toRemove.getDriverLegs());

    final List<PlanElement> elements = new ArrayList<PlanElement>();
    elements.add(driverTrip.getOriginActivity());
    elements.addAll(driverTrip.getTripElements());
    elements.add(driverTrip.getDestinationActivity());
    return TripStructureUtils.getTrips(elements, stages);
  }
 private static void unregisterPassengerFromDriverRoutes(final JointTrip toRemove) {
   for (Leg driverLeg : toRemove.getDriverLegs()) {
     final DriverRoute route = (DriverRoute) driverLeg.getRoute();
     route.removePassenger(toRemove.getPassengerId());
     if (route.getPassengersIds().isEmpty()) {
       driverLeg.setMode(TransportMode.car);
       driverLeg.setRoute(null);
     }
   }
 }