#NEWLINE# def getiterator( self , tag = None ) : #NEWLINE# #INDENT# '\n        Creates a tree iterator.  The iterator loops over this element\n        and all subelements, in document order, and returns all elements\n        with a matching tag.\n\n        If the tree structure is modified during iteration, the result\n        is undefined.\n\n        @param tag What tags to look for (default is to return all elements).\n        @return A list or iterator containing all the matching elements.\n        @defreturn list or iterator\n        ' #NEWLINE# if ( ( tag == '*' ) or ( tag is None ) or ( self . tag == tag ) ) : #NEWLINE# #INDENT# ( yield self ) #NEWLINE# #UNINDENT# for node in self . _children : #NEWLINE# #INDENT# for item in node . getiterator ( self ) : #NEWLINE# #INDENT# ( yield item )