added helper function to get longest common prefix entries