### Question:
BinaryTreeWalker extends Walker<N> { @Override public Stream<N> postOrderFrom(Iterable<? extends N> roots) { return whileNotNull(new PostOrder(roots)::nextOrNull); } BinaryTreeWalker(UnaryOperator<N> getLeft, UnaryOperator<N> getRight); @Override Stream<N> breadthFirstFrom(Iterable<? extends N> roots); @Override Stream<N> preOrderFrom(Iterable<? extends N> roots); @Override Stream<N> postOrderFrom(Iterable<? extends N> roots); @SafeVarargs final Stream<N> inOrderFrom(N... roots); Stream<N> inOrderFrom(Iterable<? extends N> roots);  }### Answer:
@Test public void postOrder_noRoot() { assertThat(Tree.<String>walker().postOrderFrom().map(Tree::value)) .isEmpty(); }
@Test public void postOrder_singleNode() { assertThat(Tree.<String>walker().postOrderFrom(tree("foo")).map(Tree::value)) .containsExactly("foo"); }
@Test public void postOrder_leftNodeIsNull() { Tree<String> tree = tree("foo").setRight("right"); assertThat(Tree.<String>walker().postOrderFrom(tree).map(Tree::value)) .containsExactly("right", "foo") .inOrder(); }
@Test public void postOrder_deep() { Tree<String> tree = tree("a") .setLeft(tree("b") .setLeft("c") .setRight(tree("d").setLeft("e"))) .setRight(tree("f") .setLeft(tree("g").setRight("h")) .setRight("i")); assertThat(Tree.<String>walker().postOrderFrom(tree).map(Tree::value)) .containsExactly("c", "e", "d", "b", "h", "g", "i", "f", "a") .inOrder(); }
@Test public void postOrder_twoRoots() { Tree<String> tree1 = tree("a") .setLeft("b") .setRight(tree("c").setRight("d")); Tree<String> tree2 = tree("e") .setLeft(tree("f") .setLeft("g") .setRight("h")); assertThat(Tree.<String>walker().postOrderFrom(tree1, tree2).map(Tree::value)) .containsExactly("b", "d", "c", "a", "g", "h", "f", "e") .inOrder(); }
@Test public void postOrder_infiniteLeft() { assertThat(Tree.<Integer>walker().postOrderFrom(Tree.leftFrom(1)).map(Tree::value).limit(0)) .isEmpty(); }
@Test public void postOrder_infiniteRight() { assertThat(Tree.<Integer>walker().postOrderFrom(Tree.rightFrom(1)).map(Tree::value).limit(0)) .isEmpty(); }
@Test public void postOrder_alternating() { assertThat(Tree.<Integer>walker().postOrderFrom(Tree.leftThenRight(1)).map(Tree::value).limit(0)) .isEmpty(); }
@Test public void postOrder_finiteLeft_infiniteRight() { Tree<Integer> tree = tree(1).setLeft(2).setRight(Tree.leftFrom(3)); assertThat(Tree.<Integer>walker().postOrderFrom(tree).map(Tree::value).limit(1)) .containsExactly(2) .inOrder(); }