src/Form/Hydrator/TreeHydrator.php
private function hydrateTree(NodeInterface $object, \ArrayObject $currentData = null)
    {
        if (null === $currentData) {
            $currentData = $this->hydrateData['__root__'];
        }

        if ('set' == $currentData['do']) {
            $object
                ->setName($currentData['name'])
                ->setValue($currentData['value'])
                ->setPriority($currentData['priority'])
            ;
        }

        if (isset($this->hydrateData[$currentData['current']])) {
            foreach ($this->hydrateData[$currentData['current']] as $childData) {
                $child = $this->findOrCreateChild($object, $childData['id']);
                if ('remove' == $childData['do']) {
                    $object->removeChild($child);
                } else {
                    $this->hydrateTree($child, $childData);
                }
            }
        }

        return $object;
    }
private function hydrateTree(NodeInterface $object, \ArrayObject $currentData = null)
    {
        if (null === $currentData) {
            $currentData = $this->hydrateData['__root__'];
        }

        if ('set' == $currentData['do']) {
            $object
                ->setName($currentData['name'])
                ->setValue($currentData['value'])
                ->setPriority($currentData['priority'])
            ;
        }

        if (isset($this->hydrateData[$currentData['current']])) {
            foreach ($this->hydrateData[$currentData['current']] as $childData) {
                $child = $this->findOrCreateChild($object, $childData['id']);
                if ('remove' == $childData['do']) {
                    $object->removeChild($child);
                } else {
                    $this->hydrateTree($child, $childData);
                }
            }
        }

        return $object;
    }
Recursively hydrate the tree structure.

Items not present in the {@link hydrateData} are removed,
new items are created accordingly.

@param NodeInterface $object
@param \ArrayObject $currentData

@return NodeInterface