Iterator<Entry<NonTerminal, Queue<State>>> iter = dependencies.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<NonTerminal, Queue<State>> ee = iter.next();
        ...
        iter.remove();
    }