This is the same fix than commit "fix parent missing detection and donwload" (c6cf2b81), but factorized.