real_path(): properly handle nonexistent top-level paths