patching nearestPath to first check if metadata exists #348