def get_nodes(node, klass):
 for child in node.children:
  if isinstance(child, klass):
   (yield child)
  for grandchild in get_nodes(child, klass):
   (yield grandchild)

def get_nodes ( node , klass ) : for child in node . children : if isinstance ( child , klass ) : ( yield child ) for grandchild in get_nodes ( child , klass ) : ( yield grandchild )
return an iterator on all children node of the given klass .