src/Form/Hydrator/TreeHydrator.php
private function flattenTree($tree, &$data, $curId = '1')
    {
        $data[] =
        new \ArrayObject([
            'id' => $tree->getId(),
            'current' => $curId,
            'name' => $tree->getName(),
            'value' => $tree->getValue(),
            'priority' => $tree->getPriority(),
            'do' => 'nothing',
        ]);

        if ($tree->hasChildren()) {
            foreach ($tree->getChildren() as $i => $child) {
                $this->flattenTree($child, $data, $curId . '-' . ($i + 1));
            }
        }
    }
private function flattenTree($tree, &$data, $curId = '1')
    {
        $data[] =
        new \ArrayObject([
            'id' => $tree->getId(),
            'current' => $curId,
            'name' => $tree->getName(),
            'value' => $tree->getValue(),
            'priority' => $tree->getPriority(),
            'do' => 'nothing',
        ]);

        if ($tree->hasChildren()) {
            foreach ($tree->getChildren() as $i => $child) {
                $this->flattenTree($child, $data, $curId . '-' . ($i + 1));
            }
        }
    }
Recursively flattens a tree structure.

@param NodeInterface $tree
@param array $data
@param string $curId