Prune LinkedKegs relative to correct path

Fixes #16948.