def occur_check(var, x):
 if (var == x):
  return True
 elif isinstance(x, Compound):
  return occur_check(var, x.args)
 elif is_args(x):
  if any((occur_check(var, xi) for xi in x)):
   return True
 return False

def occur_check ( var , x ) : if ( var == x ) : return True elif isinstance ( x , Compound ) : return occur_check ( var , x . args ) elif is_args ( x ) : if any ( ( occur_check ( var , xi ) for xi in x ) ) : return True return False
var occurs in subtree owned by x? .