def parse_mul_tree(root):
 mul_info = is_mul(root)
 if (mul_info is None):
  neg_info = is_neg(root)
  if (neg_info is None):
   return [False, root]
  else:
   (neg, sub_tree) = parse_mul_tree(neg_info)
   return [(not neg), sub_tree]
 else:
  return [False, list(map(parse_mul_tree, mul_info))]

def parse_mul_tree ( root ) : mul_info = is_mul ( root ) if ( mul_info is None ) : neg_info = is_neg ( root ) if ( neg_info is None ) : return [ False , root ] else : ( neg , sub_tree ) = parse_mul_tree ( neg_info ) return [ ( not neg ) , sub_tree ] else : return [ False , list ( map ( parse_mul_tree , mul_info ) ) ]
parse a tree of multiplications starting at the given root .