def _cmp_by_cluster_list(path1, path2):
    """Selects the route received from the peer with the shorter
    CLUSTER_LIST length. [RFC4456]

    The CLUSTER_LIST length is evaluated as zero if a route does not
    carry the CLUSTER_LIST attribute.
    """
    def _get_cluster_list_len(path):
        c_list = path.get_pattr(BGP_ATTR_TYPE_CLUSTER_LIST)
        if c_list is None:
            return 0
        else:
            return len(c_list.value)

    c_list_len1 = _get_cluster_list_len(path1)
    c_list_len2 = _get_cluster_list_len(path2)
    if c_list_len1 < c_list_len2:
        return path1
    elif c_list_len1 > c_list_len2:
        return path2
    else:
        return None
Selects the route received from the peer with the shorter
    CLUSTER_LIST length. [RFC4456]

    The CLUSTER_LIST length is evaluated as zero if a route does not
    carry the CLUSTER_LIST attribute.