/** * Recursively find all the child items that need to be listed * * @param DataObject $parent * @param int $depth */ protected function getIdsFrom($parent, $depth) { if ($depth >= $this->Depth) { return; } $ids = array(); foreach ($parent->Children() as $kid) { $ids[] = $kid->ID; $childIds = $this->getIdsFrom($kid, $depth + 1); if ($childIds) { $ids = array_merge($ids, $childIds); } } return $ids; }