48 nodes = list(filter(lambda x, l=stage: x not in l, nodes)) |
48 nodes = list(filter(lambda x, l=stage: x not in l, nodes)) |
49 while nodes: |
49 while nodes: |
50 previousStageChildren = [] |
50 previousStageChildren = [] |
51 nodelen = len(nodes) |
51 nodelen = len(nodes) |
52 |
52 |
53 # second stage are those nodes, which are direct children of the first stage |
53 # second stage are those nodes, which are direct children of the |
|
54 # first stage |
54 for node in stage: |
55 for node in stage: |
55 for child in children.get(node, []): |
56 for child in children.get(node, []): |
56 if child not in previousStageChildren and child not in taken: |
57 if child not in previousStageChildren and child not in taken: |
57 previousStageChildren.append(child) |
58 previousStageChildren.append(child) |
58 elif child in taken and noRecursion: |
59 elif child in taken and noRecursion: |