Fix recursive parent linking check