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;
    }
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;
    }
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 ; }
Take the data structure returned from "sort_into_children" and flatten it back
into an array. It does a depth first flatten which maintains the reply ordering.

@param array $items Items in the data structure returned by "sort_into_children"
@return array A flat array.
Take the data structure returned from sort_into_children and flatten it back into an array . It does a depth first flatten which maintains the reply ordering .