code: public int getHeadwayForStopByRoute (String stop_id, String route_id, LocalDate date, LocalTime from, LocalTime to) {
  
          List<Trip> tripsForStop = feed.getDistinctTripsForStop(stop_id).stream()
                  .filter(trip -> feed.trips.get(trip.trip_id).route_id.equals(route_id))
                  .filter(trip -> feed.services.get(trip.service_id).activeOn(date))
                  .collect(Collectors.toList());
  
          return getStopHeadwayForTrips(stop_id, tripsForStop, from, to);
      }
docs: Get the average headway, in seconds, for a route at a stop over a time window.
  @param stop_id
  @param route_id
  @param date
  @param from
  @param to
  @return avg. headway (in seconds)