class 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;
  }

  public  BstIterator(TreeNode<T> root);

}