Modify path_to to support arbitrary length paths