def uri_unsplit_tree(uri_tree):
    """
    Unsplit a coded URI tree, which must also be coalesced by
    uri_tree_normalize().
    """
    scheme, authority, path, query, fragment = uri_tree
    if authority:
        user, passwd, host, port = authority
        if user and passwd:
            userinfo = user + ':' + passwd
        elif user:
            userinfo = user
        elif passwd:
            userinfo = ':' + passwd
        else:
            userinfo = None
        if host and port:
            hostport = host + ':' + port
        elif host:
            hostport = host
        elif port:
            hostport = ':' + port
        else:
            hostport = None
        if userinfo and hostport:
            authority = userinfo + '@' + hostport
        elif userinfo:
            authority = userinfo + '@'
        elif hostport:
            authority = hostport
        else:
            authority = None
    if query:
        query = unsplit_query(query)
    uri = ''
    if scheme:
        uri += scheme + ':'
    if authority:
        uri += '//' + authority
    if path:
        if (not authority) and path[0:2] == '//':
            uri += '//'
        uri += path
    if query:
        uri += '?' + query
    if fragment:
        uri += '#' + fragment
    return uri