'Export the hierarchy beneath a node
@param node_id: the root node
@param prefix: prefix for the hierarchy column in the output
@param depth: the maximum depth to export
@param level: the current recursion level (internal)
@param path: the path dict for this node (internal)
@param hcol: the hierarchy column in the input data
@param columns: the list of columns to export
@param data: the input data dict {node_id: row}
@param node_list: the output data list (will be appended to)
@returns: the output data list
@todo: pass the input data as list and retain the original
order when recursing into child nodes?'

def export_node(self, node_id, prefix='_hierarchy', depth=None, level=0, path=None, hcol=None, columns=None, data=None, node_list=None):

    if (node_list is None):
        node_list = []
    if ((depth is not None) and (level > depth)):
        return node_list
    node = self.nodes.get(node_id)
    if (not node):
        return node_list
    if data:
        if (node_id not in data):
            return node_list
        node_data = data.get(node_id)
    else:
        node_data = {}
    if (path is None):
        if (depth is None):
            depth = self.depth(node_id)
        path = dict(((('%s.%s' % (prefix, l)), '') for l in xrange((depth + 1))))
    label = (node_data.get(hcol) if hcol else node_id)
    path[('%s.%s' % (prefix, level))] = label
    record = dict(path)
    if columns:
        for column in columns:
            if (columns == hcol):
                continue
            record[column] = node_data.get(column)
    node_list.append(record)
    children = node['s']
    for child in children:
        self.export_node(child, prefix=prefix, depth=depth, level=(level + 1), path=dict(path), hcol=hcol, columns=columns, data=data, node_list=node_list)
    return node_list
