recursive file_by_path: handle some corner cases