determine the longest match route