Code was not handling properly the case where the new object that should replace the old one in given collection is already in the collection. In such case, remove the old object from the collection, but do not attempt to add the new one again.
Code was not handling properly the case where the new object that should replace the old one in given collection is already in the collection. In such case, remove the old object from the collection, but do not attempt to add the new one again.