private function hierarchyToFlatArray($items) {
        $flatArray = [];
        foreach($items as $item) {
            $flatArray[] = $item->getId();
            // TODO generalize
            if($items->getChildren()->count() > 0) {
                $flatArray = array_merge($flatArray, $this->hierarchyToFlatArray($items->getChildren()));
            }
        }
        return $flatArray;
    }