An intelligent collapse algorithm for long paths