def segment_lists_are_equal(val1, val2):
    """
    Returns True if the two lists hold the same set of segments, otherwise
    returns False.
    """

    if len(val1) != len(val2):
        return False

    val1.sort()
    val2.sort()

    if val1 is None:  # get rid of this later -- we don't any empty dict values!
        if val2 is not None:
            return False
    elif val2 is None:
        if val1 is not None:
            return False
    for i in range(len(val1)):
        if val1[i] != val2[i]:
            return False

    return True