generate a tree of the given data with the path property.

@param array $data

@return array
774021
public function convert($data)
    {
        if (empty($data)) {
            return [];
        }

        $map = [];
        $minDepth = 99;
        foreach ($data as $item) {
            $path = rtrim('/root' . $item['path'], '/');
            $map[$path] = $item;

            $parts = explode('/', $path);
            $parts = array_filter($parts);
            $depth = count($parts);
            if ($minDepth > $depth) {
                $minDepth = $depth;
            }
        }

        uksort(
            $map,
            function($a, $b) use ($map) {
                $depthDifference = substr_count($a, '/') - substr_count($b, '/');
                if ($depthDifference > 0) {
                    return 1;
                } elseif ($depthDifference < 0) {
                    return -1;
                } else {
                    $aPosition = array_search($a, array_keys($map));
                    $bPosition = array_search($b, array_keys($map));

                    return ($aPosition < $bPosition) ? -1 : 1;
                }
            }
        );

        $tree = $this->explodeTree($map, '/');

        for ($i = 0; $i < $minDepth - 1; ++$i) {
            $tree['children'] = array_values($tree['children']);
            if (!array_key_exists('children', $tree) || !array_key_exists(0, $tree['children'])) {
                return [];
            }

            $tree = $tree['children'][0];
        }

        $tree = $this->toArray($tree);

        return $tree['children'];
    }
234781
public static function deserializeObject(array $data)
    {
        $result = new static($data['resourceType'], isset($data['created']) ? Helper::string2dateTime($data['created']) : null);
        if (isset($data['lastModified'])) {
            $result->lastModified = Helper::string2dateTime($data['lastModified']);
        }
        if (isset($data['location'])) {
            $result->location = $data['location'];
        }
        if (isset($data['version'])) {
            $result->version = $data['version'];
        }

        return $result;
    }
461879
public static function makeNested(array $data): array
    {
        $result = [];
        foreach ($data as $key => $value) {
            $keyParts = explode(':', $key);
            $current =& $result;
            foreach (static::tail($keyParts) as $keyPart) {
                if (!array_key_exists($keyPart, $current)) {
                    $current[$keyPart] = [];
                }
                $current =& $current[$keyPart];
            }
            $current[static::end($keyParts)] = $value;
        }
        return $result;
    }
917938
private function createNodeFromArray(array $data = []): Node
    {
        if (null === $this->serializer) {
            $this->serializer = new PhpArraySerializer();
        }

        /** @var Node $node */
        $node = $this->serializer->deserialize($data);
        return $node;
    }
587857
public function generateTree($items)
    {
        foreach ($items->reverse()->all() as $index => $item) {
            $parent = $this->findParent($items, $item);

            if (isset($parent)) {
                $parent->setChild($item);

                $items->forget($index);
            }
        }

        return $items;
    }
1119260
public function process($data)
    {
        $check = true;
        if ($this->pathFilterRegex && !preg_match($this->pathFilterRegex, $this->path)) {
            $check = false;
        }

        if (!is_array($data) && !is_object($data)) {
            if ($check && $data === $this->search) {
                $this->affectedPaths[] = $this->path;
                return $this->replace;
            } else {
                return $data;
            }
        }

        $originalKeys = $data instanceof \stdClass ? get_object_vars($data) : $data;

        if ($check) {
            $diff = new JsonDiff($data, $this->search, JsonDiff::STOP_ON_DIFF);
            if ($diff->getDiffCnt() === 0) {
                $this->affectedPaths[] = $this->path;
                return $this->replace;
            }
        }

        $result = array();

        foreach ($originalKeys as $key => $originalValue) {
            $path = $this->path;
            $pathItems = $this->pathItems;
            $actualKey = $key;
            $this->path .= '/' . JsonPointer::escapeSegment($actualKey);
            $this->pathItems[] = $actualKey;

            $result[$key] = $this->process($originalValue);

            $this->path = $path;
            $this->pathItems = $pathItems;
        }

        return $data instanceof \stdClass ? (object)$result : $result;
    }
1002028
public function generate(array $data): string
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $folder = $recordFinder->findDemoFolderObject();
        return $folder->getCombinedIdentifier();
    }
1150362
public function route($data)
    {
        if (is_array($data)) {
            $path = $data[0];
            $pkg = $data[1];
        } else {
            $path = $data;
        }

        $path = trim($path, '/');
        $pkgHandle = null;
        if ($pkg) {
            if (is_object($pkg)) {
                $pkgHandle = $pkg->getPackageHandle();
            } else {
                $pkgHandle = $pkg;
            }
        }

        $route = '/ccm';
        if ($pkgHandle) {
            $route .= "/{$pkgHandle}";
        } else {
            $route .= '/system';
        }

        $route .= "/{$path}";

        return $route;
    }
442168
public function convertTypeDescendants(array $data = null)
    {
        $result = [];

        if (empty($data)) {
            return $result;
        }

        foreach (array_filter($data, 'is_array') as $itemData) {

            $container = new TypeDefinitionContainer();

            $typeDefinition = $this->convertTypeDefinition($itemData[JSONConstants::JSON_TYPESCONTAINER_TYPE] ?? []);
            if ($typeDefinition !== null) {
                $container->setTypeDefinition($typeDefinition);
            }

            $container->setChildren(
                $this->convertTypeDescendants($itemData[JSONConstants::JSON_TYPESCONTAINER_CHILDREN] ?? [])
            );

            $container->setExtensions($this->convertExtension($data, JSONConstants::getTypesContainerKeys()));

            $result[] = $container;
        }

        return $result;
    }
191288
private function itemsFromArray(array $data): array
    {
        $objects = [];
        foreach ($data[$this->key()] as $objectData) {
            $objects[] = $this->item->from($objectData);
        }
        return $objects;
    }
1083893
public function parse($data, array $paths = []): iterable
    {
        \assert(\is_array($data) === true || \is_object($data) === true || $data === null);

        $this->paths = $this->normalizePaths($paths);

        $rootPosition = $this->factory->createPosition(
            ParserInterface::ROOT_LEVEL,
            ParserInterface::ROOT_PATH,
            null,
            null
        );

        if ($this->schemaContainer->hasSchema($data) === true) {
            yield $this->createDocumentDataIsResource($rootPosition);
            yield from $this->parseAsResource($rootPosition, $data);
        } elseif ($data instanceof SchemaIdentifierInterface) {
            yield $this->createDocumentDataIsIdentifier($rootPosition);
            yield $this->parseAsIdentifier($rootPosition, $data);
        } elseif (\is_array($data) === true) {
            yield $this->createDocumentDataIsCollection($rootPosition);
            yield from $this->parseAsResourcesOrIdentifiers($rootPosition, $data);
        } elseif ($data instanceof Traversable) {
            $data = $data instanceof IteratorAggregate ? $data->getIterator() : $data;
            yield $this->createDocumentDataIsCollection($rootPosition);
            yield from $this->parseAsResourcesOrIdentifiers($rootPosition, $data);
        } elseif ($data === null) {
            yield $this->createDocumentDataIsNull($rootPosition);
        } else {
            throw new InvalidArgumentException(_(static::MSG_NO_SCHEMA_FOUND, \get_class($data)));
        }
    }
849374
public function mapBlocks(array $data): array
    {
        $blocks = [];

        foreach ($data as $dataItem) {
            $blockId = (int) $dataItem['id'];
            $locale = $dataItem['locale'];

            if (!isset($blocks[$blockId])) {
                $blocks[$blockId] = [
                    'id' => $blockId,
                    'layoutId' => (int) $dataItem['layout_id'],
                    'depth' => (int) $dataItem['depth'],
                    'path' => $dataItem['path'],
                    'parentId' => $dataItem['parent_id'] > 0 ? (int) $dataItem['parent_id'] : null,
                    'placeholder' => $dataItem['placeholder'],
                    'position' => $dataItem['parent_id'] > 0 ? (int) $dataItem['position'] : null,
                    'definitionIdentifier' => $dataItem['definition_identifier'],
                    'viewType' => $dataItem['view_type'],
                    'itemViewType' => $dataItem['item_view_type'],
                    'name' => $dataItem['name'],
                    'isTranslatable' => (bool) $dataItem['translatable'],
                    'mainLocale' => $dataItem['main_locale'],
                    'alwaysAvailable' => (bool) $dataItem['always_available'],
                    'status' => (int) $dataItem['status'],
                    'config' => $this->buildParameters((string) $dataItem['config']),
                ];
            }

            $blocks[$blockId]['parameters'][$locale] = $this->buildParameters((string) $dataItem['parameters']);
            $blocks[$blockId]['availableLocales'][] = $locale;
        }

        return array_values(
            array_map(
                static function (array $blockData): Block {
                    ksort($blockData['parameters']);
                    sort($blockData['availableLocales']);

                    return Block::fromArray($blockData);
                },
                $blocks
            )
        );
    }
1186982
private static function buildNodes(array $data): MapInterface
    {
        $nodes = new Map('int', Node::class);

        foreach ($data as $response) {
            foreach ($response['graph']['nodes'] as $node) {
                $labels = Set::of('string', ...\array_values($node['labels']));

                $nodes = $nodes->put(
                    (int) $node['id'],
                    new Node\Node(
                        new Id((int) $node['id']),
                        $labels,
                        self::buildProperties($node['properties'])
                    )
                );
            }
        }

        return $nodes;
    }
321048
public function create(array $data = [])
    {
        $collection = parent::create($data);

        if ($this->getCurrentCategory() && $this->getCurrentCategory()->getLevel() >= 2) {
            $collection->addAttributeToFilter('entity_id', ['neq' => (int) $this->getCurrentCategory()->getId()]);

            $rootPath      = array_slice($this->getCurrentCategory()->getPathIds(), 0, 2);
            $pathCondition = implode('/', $rootPath) . '%';
            $collection->addFieldToFilter('path', ['like' => $pathCondition]);
        }

        return $collection;
    }
756383
public static function arrayToXml(array $data)
    {
        $xml = '';
        foreach ($data as $key => $value) {
            $tag = (is_numeric($key)) ? 'item' : $key;

            $xml = (!empty($xml)) ? $xml : '';
            if (is_array($value)) {
                $xml .= "<$tag index=\"" . $key . "\">" . self::arrayToXml($value) . "</$tag>";
            } else {
                $xml .= "<$tag>" . $value . "</$tag>";
            }
        }

        return $xml;
    }
298466
public function getLocationCreateStruct(array $data)
    {
        $struct = new CreateStruct();

        $struct->contentId = $data['contentobject_id'];
        $struct->contentVersion = $data['contentobject_version'];
        $struct->hidden = $data['is_hidden'];
        $struct->invisible = $data['is_invisible'];
        $struct->mainLocationId = $data['main_node_id'];
        $struct->parentId = $data['parent_node_id'];
        $struct->pathIdentificationString = $data['path_identification_string'];
        $struct->priority = $data['priority'];
        $struct->remoteId = md5(uniqid(get_class($this), true));
        $struct->sortField = $data['sort_field'];
        $struct->sortOrder = $data['sort_order'];

        return $struct;
    }
727304
public function generate(array $data): string
    {
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
        $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_expandsingle_child');
        $childRowsToCreate = 3;
        for ($i = 0; $i < $childRowsToCreate; $i++) {
            // Insert an empty row again to have the uid already. This is useful for
            // possible further inline that may be attached to this child.
            $childFieldValues = [
                'pid' => $data['fieldValues']['pid'],
                'parentid' => $data['fieldValues']['uid'],
                'parenttable' => $data['tableName'],
            ];
            $connection->insert(
                'tx_styleguide_inline_expandsingle_child',
                $childFieldValues
            );
            $childFieldValues['uid'] = $connection->lastInsertId('tx_styleguide_inline_expandsingle_child');
            $recordData = GeneralUtility::makeInstance(RecordData::class);
            $childFieldValues = $recordData->generate('tx_styleguide_inline_expandsingle_child', $childFieldValues);
            $connection->update(
                'tx_styleguide_inline_expandsingle_child',
                $childFieldValues,
                [ 'uid' => $childFieldValues['uid'] ]
            );
        }
        return (string)$childRowsToCreate;
    }