def has_metaclass(parent):
 for node in parent.children:
  if (node.type == syms.suite):
   return has_metaclass(node)
  elif ((node.type == syms.simple_stmt) and node.children):
   expr_node = node.children[0]
   if ((expr_node.type == syms.expr_stmt) and expr_node.children):
    left_side = expr_node.children[0]
    if (isinstance(left_side, Leaf) and (left_side.value == '__metaclass__')):
     return True
 return False

def has_metaclass ( parent ) : for node in parent . children : if ( node . type == syms . suite ) : return has_metaclass ( node ) elif ( ( node . type == syms . simple_stmt ) and node . children ) : expr_node = node . children [ 0 ] if ( ( expr_node . type == syms . expr_stmt ) and expr_node . children ) : left_side = expr_node . children [ 0 ] if ( isinstance ( left_side , Leaf ) and ( left_side . value == '__metaclass__' ) ) : return True return False
we have to check the cls_node without changing it .