<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def multigraph_collect(G, traversal, attrib=None):
 """ Given a MultiDiGraph traversal, collect attributes along it. Parameters G: networkx.MultiDiGraph traversal: (n) list of (node, instance) tuples attrib: dict key, name to collect. If None, will return all Returns collected: (len(traversal) - 1) list of attributes """


    collected = []
    for u, v in util.pairwise(traversal):
        attribs = G[u[0]][v[0]][v[1]]
        if attrib is None:
            collected.append(attribs)
        else:
            collected.append(attribs[attrib])
    return collected