public function flatten_children(array $items) : array {
        $result = [];

        foreach ($items as [$item, $children]) {
            $result[] = $item;
            $result = array_merge($result, $this->flatten_children($children));
        }

        return $result;
    }