def _resolve_aliases(bindings):
 for (var, value) in bindings.items():
  while (isinstance(value, Variable) and (value in bindings)):
   value = bindings[var] = bindings[value]

def _resolve_aliases ( bindings ) : for ( var , value ) in bindings . items ( ) : while ( isinstance ( value , Variable ) and ( value in bindings ) ) : value = bindings [ var ] = bindings [ value ]
replace any bound aliased vars with their binding; and replace any unbound aliased vars with their representative var .