Extract parent/child path repair logic into a helper function.