def deconstruct(s, variables=()):
 if (s in variables):
  return Variable(s)
 if isinstance(s, (Variable, CondVariable)):
  return s
 if ((not isinstance(s, Basic)) or s.is_Atom):
  return s
 return Compound(s.__class__, tuple((deconstruct(arg, variables) for arg in s.args)))

def deconstruct ( s , variables = ( ) ) : if ( s in variables ) : return Variable ( s ) if isinstance ( s , ( Variable , CondVariable ) ) : return s if ( ( not isinstance ( s , Basic ) ) or s . is_Atom ) : return s return Compound ( s . __class__ , tuple ( ( deconstruct ( arg , variables ) for arg in s . args ) ) )
turn a sympy object into a compound .