<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def docinfo2dict(doctree):
 """ Return the docinfo field list from a doctree as a dictionary Note: there can be multiple instances of a single field in the docinfo. Since a dictionary is returned, the last instance's value will win. Example: pub = rst2pub(rst_string) print docinfo2dict(pub.document) """

    nodes = doctree.traverse(docutils.nodes.docinfo)
    md = {}
    if not nodes:
        return md
    for node in nodes[0]:
        # copied this logic from Sphinx, not exactly sure why they use it, but
        # I figured it can't hurt
        if isinstance(node, docutils.nodes.authors):
            md['authors'] = [author.astext() for author in node]
        elif isinstance(node, docutils.nodes.TextElement):  # e.g. author
            md[node.__class__.__name__] = node.astext()
        else:
            name, body = node
            md[name.astext()] = body.astext()
    return md