def _commonPrefix(L):
    """Takes a list of lists, and returns their longest common prefix."""
    assert L
    if len(L) == 1:
        return L[0]

    for n in range(1, max(map(len, L)) + 1):
        prefix = L[0][:n]
        for item in L[1:]:
            if prefix != item[:n]:
                return prefix[0:-1]

    assert False