public function generateTree($items, $relations)
    {
        $children = ArrayHelper::map($relations, 'child', 'parent');
        foreach ($relations as $relation) {
            if (!isset($items[$relation['child']]) || !isset($items[$relation['parent']])) {
                continue;
            }
            $tree = $items[$relation['parent']]['childrenTree'];
            $tree[] = &$items[$relation['child']];
            $items[$relation['parent']]['childrenTree'] = $tree;
        }

        return array_diff_key($items, $children);
    }