private function generateTreeByPath(array $contents, $uuid)
    {
        $childrenByPath = [];

        foreach ($contents as $content) {
            $path = PathHelper::getParentPath($content->getPath());
            if (!isset($childrenByPath[$path])) {
                $childrenByPath[$path] = [];
            }

            $order = $content['order'];
            while (isset($childrenByPath[$path][$order])) {
                ++$order;
            }

            $childrenByPath[$path][$order] = $content;
        }

        foreach ($contents as $content) {
            if (!isset($childrenByPath[$content->getPath()])) {
                if ($content->getId() === $uuid) {
                    $content->setChildren([]);
                }

                continue;
            }

            ksort($childrenByPath[$content->getPath()]);

            $content->setChildren(array_values($childrenByPath[$content->getPath()]));
        }

        if (!array_key_exists('/', $childrenByPath) || !is_array($childrenByPath['/'])) {
            return [];
        }

        ksort($childrenByPath['/']);

        return array_values($childrenByPath['/']);
    }