code: def flatten(cls, args):
      # quick-n-dirty flattening for And and Or
      args_queue = list(args)
      res = []
  
      while True:
          try:
              arg = args_queue.pop(0)
          except IndexError:
              break
          if isinstance(arg, Logic):
              if isinstance(arg, cls):
                  args_queue.extend(arg.args)
                  continue
          res.append(arg)
  
      args = tuple(res)
      return args
  
imports: from __future__ import annotations
  from typing import Optional
label_desc: Use image node_id 2 for calling the AndOr_Base obj's underlying member method code with example usage: obj.flatten(cls, args) and returns: args