I would recommend not removing elements of Part while iterating over the header contents...you may be changing the underlying data without the Enumerator knowing (I am not familiar with the API so cannot say this for sure, but directly modifying a Collection while iterating over the contents should not be done - in the case of an Iterator often times a ConcurrentModificationException will be thrown). Suggest copying the headers into another local List or Set, then loop over that Collection removing them from the Part one by one.