public function linkingRecords(): array
    {
        $union = DB::table('change')
            ->where('gedcom_id', '=', $this->tree()->id())
            ->whereContains('new_gedcom', '@' . $this->xref() . '@')
            ->where('new_gedcom', 'NOT LIKE', '0 @' . $this->xref() . '@%')
            ->select(['xref']);

        $xrefs = DB::table('link')
            ->where('l_file', '=', $this->tree()->id())
            ->where('l_to', '=', $this->xref())
            ->select('l_from')
            ->union($union)
            ->pluck('l_from');

        return $xrefs->map(function (string $xref): GedcomRecord {
            return GedcomRecord::getInstance($xref, $this->tree);
        })->all();
    }