Add finding the longest common prefix