match consecutive needles to paths