code: def subclasses(cls, leaves=False):
      
      stack = [cls]
      subcls = []
      while stack:
          c = stack.pop()
          c_subs = c.__subclasses__()
          stack.extend(c_subs)
          if not leaves or not c_subs:
              subcls.append(c)
      return subcls
docs: List all subclasses of the given class, including itself.
  
      If `leaves=True`, only returns classes which have no subclasses themselves.
  
      :type cls: type
      :param leaves: Only return leaf classes
      :type leaves: bool
      :rtype: list[type]