#NEWLINE# def _location_footprint( locations ) : #NEWLINE# #INDENT# '\n    Given a list of locations, generate the footprint of those by walking up parents.\n\n    Returns a dict of location ids to location objects.\n    ' #NEWLINE# all_locs = LocationSet ( locations ) #NEWLINE# queue = list ( locations ) #NEWLINE# while queue : #NEWLINE# #INDENT# loc = queue . pop ( ) #NEWLINE# if ( loc . location_id not in all_locs ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# parent = loc . parent #NEWLINE# if ( queue and ( parent . location_id not in all_locs ) and _valid_parent_type ( loc ) ) : #NEWLINE# #INDENT# all_locs . add_location ( parent ) #NEWLINE# queue . append ( parent ) #NEWLINE# #UNINDENT# #UNINDENT# return all_locs