### Question:
BstIterator implements Iterator<TreeNode<T>> { @Override public boolean hasNext() { return !pathStack.isEmpty(); } BstIterator(TreeNode<T> root); @Override boolean hasNext(); @Override TreeNode<T> next();  }### Answer:
@Test void hasNextForEmptyTree() { BstIterator<Integer> iter = new BstIterator<>(emptyRoot); assertFalse(iter.hasNext(), "hasNext() should return false for empty tree."); }
@Test void hasNextForPopulatedTree() { BstIterator<Integer> iter = new BstIterator<>(nonEmptyRoot); assertTrue(iter.hasNext(), "hasNext() should return true for populated tree."); }
@Test void hasNextForEmptyTree() { var iter = new BstIterator<>(emptyRoot); assertFalse(iter.hasNext(), "hasNext() should return false for empty tree."); }
@Test void hasNextForPopulatedTree() { var iter = new BstIterator<>(nonEmptyRoot); assertTrue(iter.hasNext(), "hasNext() should return true for populated tree."); }