Change/complete the BSTIterator.java class so that an enhanced for loop can be used to traverse the tree in the traversal type set by the logical level using the setTraversalType method. You will also need to make appropriate changes to the iterator method in BinarySearchTree.java. Your work for Part 2 is allowed to compromise the existing getNext method in BinarySearchTree.java; i.e., you are not required to have both an effective BSTIterator class and a working getNext method.
BSTIterator:
package iterators;
import java.util.Iterator;
public class BSTIterator implements Iterator {
protected E rootData;
protected int size;
protected int counter;
public BSTIterator(E rootData, int size) {
this.rootData = rootData;
this.size = size;
counter = 0;
}