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