'Get the sibling nodes of a node. If the node is a root node,
this method returns all root nodes.
@param node_id: the node ID
@param category: return only nodes of this category
@param classify: return each node as tuple (id, category)
instead of just id
@param inclusive: include the start node
@param return: a set of node IDs
(or tuples (id, category), respectively)'

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

    result = set()
    nodes = self.nodes
    node = nodes.get(node_id)
    if (not node):
        return result
    parent_id = node['p']
    if (not parent_id):
        siblings = [(k, nodes[k]) for k in self.roots]
    else:
        parent = nodes[parent_id]
        if parent['s']:
            siblings = [(k, nodes[k]) for k in parent['s']]
        else:
            siblings = []
    add = result.add
    for (sibling_id, sibling_node) in siblings:
        if ((not inclusive) and (sibling_id == node_id)):
            continue
        if ((category is DEFAULT) or (category == sibling_node['c'])):
            sibling = ((sibling_id, sibling_node['c']) if classify else sibling_id)
            add(sibling)
    return result
