'Get the root node for a node. Returns the node if it is the
root node itself.
@param node_id: the node ID
@param category: find the closest node of this category rather
than the absolute root
@param classify: return the root node as tuple (id, category)
instead of just id
@return: the root node ID (or tuple (id, category), respectively)'

def root(self, node_id, category=DEFAULT, classify=False):

    nodes = self.nodes
    default = ((None, None) if classify else None)
    node = nodes.get(node_id)
    if (not node):
        return default
    this = ((node_id, node['c']) if classify else node_id)
    if ((category is not DEFAULT) and (node['c'] == category)):
        return this
    parent_id = node['p']
    if (not parent_id):
        return (this if (category is DEFAULT) else default)
    return self.root(parent_id, category=category, classify=classify)
