public function traverse(callable $inFunction, array &$inOutResult)
    {
        // We pass through a node. Therefore we call the user provided function on this node.
        $inFunction($this, $inOutResult);

        // Then we head for each child of the current node.
        foreach ($this as $child) {
            /** @var Node $child */
            if ($child->hasChildren()) {
                // The current child has children. Then let's go through it.
                $child->traverse($inFunction, $inOutResult);

                // As long as we encounter a child, we call the method recursively. Thus the method's execution's contexts pile up.
                // However, as soon as we encounter a leaf, we start to continue the execution of all previously piled up method's execution's contexts.
                // Once all piled up execution's contexts have ended, we walk through the next child.
                continue;
            }

            // The child node does not have children. This is a leaf.
            $inFunction($child, $inOutResult);
        }
    }