merge the recursion verion of the new longest path back end