def resolve_order(reg, deps):
 x = []
 for dep in deps[reg]:
  x.extend(resolve_order(dep, deps))
 x.append(reg)
 return x

def resolve_order ( reg , deps ) : x = [ ] for dep in deps [ reg ] : x . extend ( resolve_order ( dep , deps ) ) x . append ( reg ) return x
resolve the order of all dependencies starting at a given register .