public function foreignIDFilter($id = null)
    {
        if ($id === null) {
            $id = $this->getForeignID();
        }

        // Find directly applied groups
        $manyManyFilter = parent::foreignIDFilter($id);
        $query = SQLSelect::create('"Group_Members"."GroupID"', '"Group_Members"', $manyManyFilter);
        $groupIDs = $query->execute()->column();

        // Get all ancestors, iteratively merging these into the master set
        $allGroupIDs = [];
        while ($groupIDs) {
            $allGroupIDs = array_merge($allGroupIDs, $groupIDs);
            $groupIDs = DataObject::get(Group::class)->byIDs($groupIDs)->column("ParentID");
            $groupIDs = array_filter($groupIDs);
        }

        // Add a filter to this DataList
        if (!empty($allGroupIDs)) {
            $allGroupIDsPlaceholders = DB::placeholders($allGroupIDs);
            return ["\"Group\".\"ID\" IN ($allGroupIDsPlaceholders)" => $allGroupIDs];
        }

        return ['"Group"."ID"' => 0];
    }