src/Page/ProductCategory.php
public function AllChildCategoryIDs()
    {
        $ids = [$this->ID];
        $allids = [];
        do {
            $ids = ProductCategory::get()
                ->filter('ParentID', $ids)
                ->getIDList();
            $allids += $ids;
        } while (!empty($ids));

        return $allids;
    }
public function AllChildCategoryIDs()
    {
        $ids = [$this->ID];
        $allids = [];
        do {
            $ids = ProductCategory::get()
                ->filter('ParentID', $ids)
                ->getIDList();
            $allids += $ids;
        } while (!empty($ids));

        return $allids;
    }
Loop down each level of children to get all ids.