Root takes the output of [Tree] and returns the root of the tree. It does this by consuming the iterator and returning the last node, discarding everything else.
(tree iter.Seq2[*TreeNode, int])
| 316 | // It does this by consuming the iterator and returning the last node, |
| 317 | // discarding everything else. |
| 318 | func Root(tree iter.Seq2[*TreeNode, int]) *TreeNode { |
| 319 | var root *TreeNode |
| 320 | for node := range tree { |
| 321 | root = node |
| 322 | } |
| 323 | return root |
| 324 | } |
| 325 | |
| 326 | // TreeNode is the type of a node in the tree produced by [Tree]. |
| 327 | type TreeNode struct { |