def check_references(all_references):
    """
    Goes through a list of reference link and dedupe it, and if two references share the same index, throw an error.

    :param all_references: An array of references
    :return all_references_deduped: An array of references deduped.
    """
    all_references_deduped = []
    reference_indexes_used = []
    duplicated_references = []
    is_duplicated = False

    for reference in all_references:
        if reference not in all_references_deduped:

            reference_index, reference_val = reference

            if reference_index not in reference_indexes_used:
                reference_indexes_used.append(reference_index)
                all_references_deduped.append(reference)
            else:
                duplicated_references.append(reference)
                is_duplicated = True

    if is_duplicated:
        for duplicated_reference in duplicated_references:
            duplicated_reference_index, duplicated_reference_val = duplicated_reference
            print('Duplicated reference: [{}]: {}'.format(
                duplicated_reference_index, duplicated_reference_val))
        raise AssertionError

    return all_references_deduped