def unique_by_id_and_kind_sort(seq):
    """
    Due to the fact that we have duplicate content items for the same content id in our topic tree, as the way that
    we have implemented duplication of content across the topic tree.
    :param seq: an iterator of content items.
    :return: A unique, sorted list of content items.
    """
    seq.sort(key=lambda x: x.get('sort_order', 0))
    seen = {}
    result = []
    for item in seq:
        marker = item.get('id') + item.get('kind')
        if marker in seen:
            continue
        seen[marker] = 1
        result.append(item)
    return result
