Longest Prefix Match algorithm implementation