AssignedRelationshipElement aaRelationship = (AssignedRelationshipElement) aaIterator.next();
Relationship relationship = (Relationship) aaIterator.next();
  private void removeExistingRelationships(Schedule aaSchedule,                                           NewRelationshipSchedule transferringSchedule,                                           NewRelationshipSchedule receivingSchedule) {    HasRelationships transferringAsset =       transferringSchedule.getHasRelationships();    String transferringID =       ((Asset) transferringAsset).getItemIdentificationPG().getItemIdentification();    HasRelationships receivingAsset =       receivingSchedule.getHasRelationships();    String receivingID =       ((Asset) receivingAsset).getItemIdentificationPG().getItemIdentification();    //Safe because aaSchedule should be an AssignedRelationshipSchedule -     // supports iterator(). (Assumption is that AssignedRelationshipSchedule    // is only used by LPs.)    for (Iterator aaIterator = aaSchedule.iterator();         aaIterator.hasNext();) {      AssignedRelationshipElement aaRelationship =         (AssignedRelationshipElement) aaIterator.next();            Role role = (aaRelationship.getItemIDA().equals(receivingID)) ?        aaRelationship.getRoleA() : aaRelationship.getRoleB();            Collection remove =         transferringSchedule.getMatchingRelationships(role,                                                      receivingAsset,                                                      ETERNITY);            transferringSchedule.removeAll(remove);            role = (aaRelationship.getItemIDA().equals(transferringID)) ?        aaRelationship.getRoleA() : aaRelationship.getRoleB();      remove =         receivingSchedule.getMatchingRelationships(role,                                                   transferringAsset,                                                   ETERNITY);            receivingSchedule.removeAll(remove);    }  }