code: public void replaceHistory(@NonNull final Object key, @NonNull final Direction direction) {
      setHistory(getHistory().buildUpon().clear().push(key).build(), direction);
    }
docs: Replaces the history with the given key and dispatches in the given direction.