def BFS(self, root=None):
if not root:<EOL><INDENT>root = self.root()<EOL><DEDENT>queue = deque()<EOL>queue.append(root)<EOL>nodes = []<EOL>while len(queue) > <NUM_LIT:0>:<EOL><INDENT>x = queue.popleft()<EOL>nodes.append(x)<EOL>for child in x.children():<EOL><INDENT>queue.append(child)<EOL><DEDENT><DEDENT>return nodes<EOL>
Breadth-first search.

.. seealso::
   `Wikipedia BFS descritpion <http://en.wikipedia.org/wiki/Breadth-first_search>`_

:param root: first to start the search
:return: list of nodes