def mul_add_simplify(expr):
  """Turns Mul(Add(.), .) into Add(Mul(.), Mul(.),...)"""
  if expr[0] != '#Mul':
    return None
  for i in range(1, len(expr)):
    if expr[i][0] == '#Add':
      other_args = expr[1:i] + expr[i + 1:]
      return ('#Add',) + tuple((('#Mul',) + other_args + (j,)
                                for j in expr[i][1:]))