Recursively yield all descendant nodes in the tree starting at *node* (including *node* itself), in no specified order. This is useful if you only want to modify nodes in place and don't care about the context.
(node)
| 378 | |
| 379 | |
| 380 | def walk(node): |
| 381 | """ |
| 382 | Recursively yield all descendant nodes in the tree starting at *node* |
| 383 | (including *node* itself), in no specified order. This is useful if you |
| 384 | only want to modify nodes in place and don't care about the context. |
| 385 | """ |
| 386 | from collections import deque |
| 387 | todo = deque([node]) |
| 388 | while todo: |
| 389 | node = todo.popleft() |
| 390 | todo.extend(iter_child_nodes(node)) |
| 391 | yield node |
| 392 | |
| 393 | |
| 394 | class NodeVisitor(object): |
no test coverage detected