def get_tag_keys_and_values(list_of_tags):
    """Creates a dictonary of all the tag keys and values from the list of tags provided.

    If list_of_tags is:
    [
        {'n': 0, 'foo': 'bar'},
        {'n': 1},
        {'n': 2, 'foo': 'bar'},
    ]

    The returned dictonary will be:
    {
        'n': [0, 1, 2],
        'foo': ['bar'],
    }

    Notice that repeated tag values are removed and only unique values are preserved.
    """
    tag_key_values = {}

    for step_tags in list_of_tags:
        for key in step_tags:
            if key in tag_key_values:
                if step_tags[key] not in tag_key_values[key]:
                    tag_key_values[key].append(step_tags[key])
            else:
                tag_key_values[key] = [step_tags[key]]
    return tag_key_values