code: def uri_tree_precode_check(uri_tree, type_host = HOST_REG_NAME):
      
      scheme, authority, path, query, fragment = uri_tree # pylint: disable-msg=W0612
      if scheme:
          if not valid_scheme(scheme):
              raise InvalidSchemeError, "Invalid scheme %r" % (scheme,)
      if authority:
          user, passwd, host, port = authority # pylint: disable-msg=W0612
          if port and not __all_in(port, DIGIT):
              raise InvalidPortError, "Invalid port %r" % (port,)
          if type_host == HOST_IP_LITERAL:
              if host and (not __valid_IPLiteral(host)):
                  raise InvalidIPLiteralError, "Invalid IP-literal %r" % (host,)
          elif type_host == HOST_IPV4_ADDRESS:
              if host and (not __valid_IPv4address(host)):
                  raise InvalidIPv4addressError, "Invalid IPv4address %r" % (host,)
      if path:
          if authority and path[0] != '/':
              raise InvalidPathError, "Invalid path %r - non-absolute path can't be used with an authority" % (path,)
      return uri_tree
docs: Call this function to validate a raw URI tree before trying to
      encode it.