'Takes "tag" argument as the name of node (prepended by namespace, if needed and separated from it
by a space), attrs dictionary as the set of arguments, payload list as the set of textual strings
and child nodes that this node carries within itself and "parent" argument that is another node
that this one will be the child of. Also the __init__ can be provided with "node" argument that is
either a text string containing exactly one node or another Node instance to begin with. If both
"node" and other arguments is provided then the node initially created as replica of "node"
provided and then modified to be compliant with other arguments.'

def __init__(self, tag=None, attrs={}, payload=[], parent=None, nsp=None, node_built=False, node=None):

    if node:
        if (self.FORCE_NODE_RECREATION and isinstance(node, Node)):
            node = str(node)
        if (not isinstance(node, Node)):
            node = NodeBuilder(node, self)
            node_built = True
        else:
            (self.name, self.namespace, self.attrs, self.data, self.kids, self.parent, self.nsd) = (node.name, node.namespace, {}, [], [], node.parent, {})
            for key in node.attrs.keys():
                self.attrs[key] = node.attrs[key]
            for data in node.data:
                self.data.append(data)
            for kid in node.kids:
                self.kids.append(kid)
            for (k, v) in node.nsd.items():
                self.nsd[k] = v
    else:
        (self.name, self.namespace, self.attrs, self.data, self.kids, self.parent, self.nsd) = ('tag', '', {}, [], [], None, {})
    if parent:
        self.parent = parent
    self.nsp_cache = {}
    if nsp:
        for (k, v) in nsp.items():
            self.nsp_cache[k] = v
    for (attr, val) in attrs.items():
        if (attr == 'xmlns'):
            self.nsd[u''] = val
        elif attr.startswith('xmlns:'):
            self.nsd[attr[6:]] = val
        self.attrs[attr] = attrs[attr]
    if tag:
        if node_built:
            (pfx, self.name) = ([''] + tag.split(':'))[(-2):]
            self.namespace = self.lookup_nsp(pfx)
        elif ('    ' in tag):
            (self.namespace, self.name) = tag.split()
        else:
            self.name = tag
    if isinstance(payload, basestring):
        payload = [payload]
    for i in payload:
        if isinstance(i, Node):
            self.addChild(node=i)
        else:
            self.data.append(ustr(i))
