def update_migrations(self, remaining, ignored_portion, events_list):
    ''' Walk through remaining input events, and update the source location of
    the host migration. For example, if one host migrates twice:

    location A -> location B -> location C

    And the first migration is pruned, update the second HostMigration event
    to look like:

    location A -> location C

    Note: mutates remaining
    '''
    # TODO(cs): this should be moved outside of EventDag
    # TODO(cs): this algorithm could be simplified substantially by invoking
    # migrations_per_host()

    # keep track of the most recent location of the host that did not involve
    # a pruned HostMigration event
    # location is: (ingress dpid, ingress port no)
    currentloc2unprunedloc = {}

    for m in [e for e in events_list if type(e) == HostMigration]:
      src = m.old_location
      dst = m.new_location
      if m in ignored_portion:
        if src in currentloc2unprunedloc:
          # There was a prior migration in ignored_portion
          # Update the new dst to point back to the unpruned location
          unprunedlocation = currentloc2unprunedloc[src]
          del currentloc2unprunedloc[src]
          currentloc2unprunedloc[dst] = unprunedlocation
        else:
          # We are the first migration for this host in ignored_portion
          # Point to our tail
          currentloc2unprunedloc[dst] = src
      else: # m in remaining
        if src in currentloc2unprunedloc:
          # There was a prior migration in ignored_portion
          # Replace this HostMigration with a new one, with source at the
          # last unpruned location
          unpruned_loc = currentloc2unprunedloc[src]
          del currentloc2unprunedloc[src]
          new_loc = dst
          replace_migration(m, unpruned_loc, new_loc, remaining)
dataset/ETHPy150Open ucb-sts/sts/sts/event_dag.py/EventDag.update_migrations/original