class BidirectionalTracerouteAnswerer extends Answerer {

  @VisibleForTesting
  static Row toRow(BidirectionalTrace.Key key, List<BidirectionalTrace> traces) {
    // Invariant: each trace has getKey() equal to key.
    assert traces.stream().allMatch(trace -> trace.getKey().equals(key));

    List<Trace> forwardTraces =
        traces.stream()
            .map(BidirectionalTrace::getForwardTrace)
            .distinct()
            .collect(ImmutableList.toImmutableList());
    List<Trace> reverseTraces =
        traces.stream()
            .map(BidirectionalTrace::getReverseTrace)
            .filter(Objects::nonNull)
            .distinct()
            .collect(ImmutableList.toImmutableList());
    List<String> sessionHops =
        key.getNewSessions().stream()
            .map(FirewallSessionTraceInfo::getHostname)
            .collect(ImmutableList.toImmutableList());
    return Row.of(
        COL_FORWARD_FLOW,
        key.getForwardFlow(),
        COL_FORWARD_TRACES,
        forwardTraces,
        COL_NEW_SESSIONS,
        sessionHops,
        COL_REVERSE_FLOW,
        key.getReverseFlow(),
        COL_REVERSE_TRACES,
        reverseTraces);
  }

  public  BidirectionalTracerouteAnswerer(Question question, IBatfish batfish);

}