### Question:
BstIterator implements Iterator<TreeNode<T>> { @Override public TreeNode<T> next() throws NoSuchElementException { if (pathStack.isEmpty()) { throw new NoSuchElementException(); } TreeNode<T> next = pathStack.pop(); pushPathToNextSmallest(next.getRight()); return next; } BstIterator(TreeNode<T> root); @Override boolean hasNext(); @Override TreeNode<T> next();  }### Answer:
@Test void nextOverEntirePopulatedTree() { BstIterator<Integer> iter = new BstIterator<>(nonEmptyRoot); assertEquals(Integer.valueOf(1), iter.next().getVal(), "First Node is 1."); assertEquals(Integer.valueOf(3), iter.next().getVal(), "Second Node is 3."); assertEquals(Integer.valueOf(4), iter.next().getVal(), "Third Node is 4."); assertEquals(Integer.valueOf(5), iter.next().getVal(), "Fourth Node is 5."); assertEquals(Integer.valueOf(6), iter.next().getVal(), "Fifth Node is 6."); assertEquals(Integer.valueOf(7), iter.next().getVal(), "Sixth Node is 7."); }