def relateObjectLocs(obj, entities, selectF):
<EOL>try:                    obj = obj.loc <EOL>except AttributeError:  pass <EOL>try:                    func = obj.direct2dDistance <EOL>except AttributeError:  raise ValueError("<STR_LIT>"%(obj, type(obj), MapPoint))<EOL>try:                    return selectF([(func(b.loc), b) for b in entities])<EOL>except AttributeError:  return selectF([(func(b)    , b) for b in entities])<EOL>
calculate the minimum distance to reach any iterable of entities with a loc