def istoken(docgraph, node_id, namespace=None):
    """returns true, iff the given node ID belongs to a token node.

    Parameters
    ----------
    node_id : str
        the node to be checked
    namespace : str or None
        If a namespace is given, only look for tokens in the given namespace.
        Otherwise, look for tokens in the default namespace of the given
        document graph.
    """
    if namespace is None:
        namespace = docgraph.ns
    return namespace+':token' in docgraph.node[node_id]