def _merge_associative_list(alist, path, value):
    """
    Merge a value into an associative list at the given path, maintaining
    insertion order. Examples will explain it::

        >>> alist = []
        >>> _merge_associative_list(alist, ["foo", "bar"], "barvalue")
        >>> _merge_associative_list(alist, ["foo", "baz"], "bazvalue")
        >>> alist == [("foo", [("bar", "barvalue"), ("baz", "bazvalue")])]

    @param alist: An associative list of names to values.
    @param path: A path through sub-alists which we ultimately want to point to
    C{value}.
    @param value: The value to set.
    @return: None. This operation mutates the associative list in place.
    """
    for key in path[:-1]:
        for item in alist:
            if item[0] == key:
                alist = item[1]
                break
        else:
            subalist = []
            alist.append((key, subalist))
            alist = subalist
    alist.append((path[-1], value))
Merge a value into an associative list at the given path, maintaining
    insertion order. Examples will explain it::

        >>> alist = []
        >>> _merge_associative_list(alist, ["foo", "bar"], "barvalue")
        >>> _merge_associative_list(alist, ["foo", "baz"], "bazvalue")
        >>> alist == [("foo", [("bar", "barvalue"), ("baz", "bazvalue")])]

    @param alist: An associative list of names to values.
    @param path: A path through sub-alists which we ultimately want to point to
    C{value}.
    @param value: The value to set.
    @return: None. This operation mutates the associative list in place.