code: def sorted_bases(bases):
      '''If a class subclasses each class in bases (in that order), then
      this function returns the would-be python mro for the created class,
      minus <object>.
      '''
      ret = []
  
      for base in bases:
          # lst = [super(base), super(super(base)), ..., highest_base]
          lst = _bases(base)
  
          if not ret:
              ret = lst
          elif not any(b in ret for b in lst):
              ret += lst
          else:
              buf = []
              for b in lst:
                  if b in ret:
                      if buf:
                          ret = graft(ret, buf, ret.index(b))
                          buf = []
                  else:
                      buf.append(b)
              if buf:
                  ret += buf
  
      return ref sorted_bases(bases):
      '''If a class subclasses each class in bases (in that order), then
      this function returns the would-be python mro for the created class,
      minus <object>.
      '''
      ret = []
  
      for base in bases:
          # lst = [super(base), super(super(base)), ..., highest_base]
          lst = _bases(base)
  
          if not ret:
              ret = lst
          elif not any(b in ret for b in lst):
              ret += lst
          else:
              buf = []
              for b in lst:
                  if b in ret:
                      if buf:
                          ret = graft(ret, buf, ret.index(b))
                          buf = []
                  else:
                      buf.append(b)
              if buf:
                  ret += buf
  
      return ret
docs: If a class subclasses each class in bases (in that order), then
      this function returns the would-be python mro for the created class,
      minus <object>.