def GetServiceVersions(namespace):
   """
   Get all the versions for the service with specified namespace (partially) ordered
   by compatibility (i.e. any version in the list that is compatible with some version
   v in the list will preceed v)
   """
   def compare(a, b):
      if a == b:
         return 0
      if b in parentMap[a]:
         return -1
      if a in parentMap[b]:
         return 1
      return (a > b) - (a < b)

   if PY3:
      return sorted([v for (v, n) in iteritems(serviceNsMap) if n == namespace],
                    key=cmp_to_key(compare))
   else:
      return sorted([v for (v, n) in iteritems(serviceNsMap) if n == namespace],
                    compare)