def _contains(exp, cls):
 if isinstance(exp, cls):
  return True
 elif isinstance(exp, Var):
  return False
 else:
  return _contains(exp.sub, cls)

def _contains ( exp , cls ) : if isinstance ( exp , cls ) : return True elif isinstance ( exp , Var ) : return False else : return _contains ( exp . sub , cls )
does node contain a sub node of type cls .