def _append_example_to_data(data, example):
    """Append the given example to the data dictionary."""
    example_id = example['id']
    patient_id = example['patient']
    if patient_id in data:
        if example_id in data[example['patient']]:
            assert example_id == data[patient_id][example_id]['id']
            assert patient_id == data[patient_id][example_id]['patient']
            assert example['breast'] == data[patient_id][example_id]['breast']
            assert example['image'] == data[patient_id][example_id]['image']
            assert example['view'] == data[patient_id][example_id]['view']
            data[patient_id][example_id]['abnormalities'].extend(example[
                'abnormalities'])
        else:
            data[example['patient']][example['id']] = example
    else:
        data[example['patient']] = {example['id']: example}
