[1.6.x] Fixed #21662 -- Kept parent reference in prepared geometry

Thanks Robert Scott for the report.
Backport of 542198c1d0 from master.