code: def normalize_boolop(expr):
      
      optype = expr.op
      newvalues = []
      for subexpr in expr.values:
          if not isinstance(subexpr, ast.BoolOp):
              newvalues.append(subexpr)
          elif type(subexpr.op) != type(optype):
              newvalues.append(normalize_boolop(subexpr))
          else:
              # Normalize subexpression, then inline its values into the
              # top-level subexpr.
              newvalues.extend(normalize_boolop(subexpr).values)
      return ast.BoolOp(op=optype, values=newvalues)
docs: Normalize a boolop by folding together nested And/Or exprs.