patching nearestPath to first check if metadata exists

patching nearestPath to first check if metadata exists #348