nltk.breadth_first()

nltk.breadth_first(tree, children=<built-in function iter>, maxdepth=-1)[source]

Traverse the nodes of a tree in breadth-first order. (No need to check for cycles.) The first argument should be the tree root; children should be a function taking as argument a tree node and returning an iterator of the node’s children.