Solution (source code)

= Solution

Use the recorded child <list> as the <depth-first traversal> order. A <leaf of a tree> has no children, so it contributes its own identity once. Closure cancels the remaining traversal; a normal completion closes the output so that a consumer can detect end-of-fringe.

``
def dfFringe(node: Array[Node], root: NodeId, fringe: ![NodeId]): PROC = proc {
  def walk(v: NodeId): Unit = {
    val cs = node(v).children
    if (cs.isEmpty) fringe ! v
    else cs.foreach(walk)
  }
  try { walk(root) }
  catch { case _: io.threadcso.process.Stopped => () }
  finally { fringe.closeOut }
}
``

A completed finite <spanning tree> has no recursive child <graph cycle>, so this visits a finite number of <vertices>. A blocked leaf send is released if its output closes. A singleton root is itself a <leaf of a tree> and is output once. With sufficient call-stack space,
$$
\boxed{\text{emit each leaf once in child-list depth-first order; catch closure and close the port}.}
$$