Ancestor { List<S> getHistory(S skipValue) { LinkedList<S> history = new LinkedList<>(); HistoryChain<S> pointer = this.historyChain; while (pointer != null) { S payload = pointer.getState(); if (payload == null) { payload = skipValue; } history.addFirst(payload); pointer = pointer.getPrevious(); } return history; } private  Ancestor(double logProbability,
      HistoryChain<S> historyChain,
      @Nullable BiFunction<S, S, Bigram<S>> bigramProvider);   }
@Test void testGetHistory() { Ancestor<String> ancestor = Ancestor.createInitial(Ngram::create, "1", "2", "3", null); List<String> history = ancestor.getHistory("4"); assertEquals(history, Arrays.asList("1", "2", "3", "4")); }