As I think about it some more, basically what you want to do is exactly what you've done.  Find the root-most path in the database from the missing file and check that for existence.  If it's there, you can clean.  If it's not it's likely missing so prompt.

I don't think you need to even stop when you hit something with content set necessarily either, but it's probably a safe place to stop.