private static function getChildrenIdRec($ids, $className, $primaryKey, $parentIdField, $recursive)
    {
        $subIds = array_map('intval', $className::find()
            ->select($primaryKey)
            ->where([ $parentIdField => $ids ])
            ->column());
        if ( $subIds ) {
            if ( $recursive ) {
                return array_merge($subIds, self::getChildrenIdRec($subIds, $className, $primaryKey, $parentIdField, true));
            } else {
                return $subIds;
            }
        } else {
            return [];
        }
    }