def pattern_convert(grammar, raw_node_info):
 (type, value, context, children) = raw_node_info
 if (children or (type in grammar.number2symbol)):
  return pytree.Node(type, children, context=context)
 else:
  return pytree.Leaf(type, value, context=context)

def pattern_convert ( grammar , raw_node_info ) : ( type , value , context , children ) = raw_node_info if ( children or ( type in grammar . number2symbol ) ) : return pytree . Node ( type , children , context = context ) else : return pytree . Leaf ( type , value , context = context )
converts raw node information to a node or leaf instance .