code: def flatten_union(table):
      
      op = table.op()
      if isinstance(op, ops.Union):
          return toolz.concatv(
              flatten_union(op.left), [op.distinct], flatten_union(op.right)
          )
      return [table]
docs: Extract all union queries from `table`.
  
      Parameters
      ----------
      table : TableExpr
  
      Returns
      -------
      Iterable[Union[TableExpr, bool]]