From The Compiler, 3 Years ago, written in Python.
Embed
  1. def iterativeChildren(nodes):
  2.         results = []
  3.         while True:
  4.                 newNodes = []
  5.                 if not nodes:
  6.                         break
  7.                 for node in nodes:
  8.                         results.append(node['id'])
  9.                         newNodes += node['children']
  10.                 nodes = newNodes
  11.         return results