Longest prefix match for a collection of strings