diff --git a/src/hierarchy/iterator.js b/src/hierarchy/iterator.js index 7e06b620..3a17c6fd 100644 --- a/src/hierarchy/iterator.js +++ b/src/hierarchy/iterator.js @@ -1,12 +1,12 @@ export default function*() { - var node = this, current, next = [node], children, i, n; + let node = this, current, next = [node], children; do { - current = next.reverse(), next = []; + current = next, next = []; while (node = current.pop()) { yield node; if (children = node.children) { - for (i = 0, n = children.length; i < n; ++i) { - next.push(children[i]); + for (let i = 0; i < children.length; ++i) { + next.unshift(children[i]); } } }