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'];
    }