anchor.diff:    Merger = fun(_Key, V1, V2) -> max(V1, V2) end,
     orddict:merge(Merger, D1, D2).
   
  +find_latest_hb_index(ActorClock, StateClock) ->
  +  %% This is the max index that is in the Actor clock but not in the
  +  %% corresponding state clock.
  +  Fold =
  +    fun(K, V, Next) ->
  +        case orddict:find(K, StateClock) =:= {ok, V} of
  +          true -> Next;
  +          false -> max(V, Next)
  +        end
  +    end,
  +  orddict:fold(Fold, -1, ActorClock).
  +
   -else.
   
   empty_map() ->
  
positive.code:     none -> false
    end.
  
  more_interleavings_for_event(OldTrace, Event, Later, Clock, State, Index) ->
    more_interleavings_for_event(OldTrace, Event, Later, Clock, State, Index, []).
  
  more_interleavings_for_event([], _Event, _Later, _Clock, _State, _Index,
                               NewOldTrace) ->
    lists:reverse(NewOldTrace);
  more_interleavings_for_event([TraceState|Rest], Event, Later, Clock, State,
                               Index, NewOldTrace) ->
    #trace_state{
       clock_map = EarlyClockMap,
       done = [#event{actor = EarlyActor} = EarlyEvent|_],
       index = EarlyIndex
      } = TraceState,
    EarlyClock = lookup_clock_value(EarlyActor, Clock),
    Action =
      case EarlyIndex > EarlyClock of
        false -> none;
        true ->
          Dependent =
  
negative.code: 
  %%------------------------------------------------------------------------------
  
  plan_more_interleavings([], RevEarly, _SchedulerState) ->
    RevEarly;
  plan_more_interleavings([TraceState|Later], RevEarly, State) ->
    case skip_planning(TraceState, State) of
      true ->
        plan_more_interleavings(Later, [TraceState|RevEarly], State);
      false ->
        #scheduler_state{logger = _Logger} = State,
        #trace_state{
           clock_map = ClockMap,
           done = [#event{actor = Actor} = _Event|_],
           index = _Index
          } = TraceState,
        StateClock = lookup_clock(state, ClockMap),
        %% If no dependencies were found skip this altogether
        case StateClock =:= independent of
          true ->
            plan_more_interleavings(Later, [TraceState|RevEarly], State);
          false ->
            ?debug(_Logger, "~s~n", [?pretty_s(_Index, _Event)]),
            ActorClock = lookup_clock(Actor, ClockMap),
            %% Otherwise we zero-down to the latest op that happened before
            LatestHBIndex = find_latest_hb_index(ActorClock, StateClock),
            ?trace(_Logger, "   SC:~w~n", [StateClock]),
            ?trace(_Logger, "   AC:~w~n", [ActorClock]),
            ?debug(_Logger, "  Next @ ~w~n", [LatestHBIndex]),
            NewRevEarly =
              more_interleavings_for_event(
                TraceState, RevEarly, LatestHBIndex, StateClock, Later, State),
            plan_more_interleavings(Later, NewRevEarly, State)
        end
    end.
  
  