iterating over a SplPriorityQueue actually also have side effects: it removes elements during the iteration