yield all nodes that dominate one or more RST relations in the given
    document graph (in no particular order).

    Parameters
    ----------
    docgraph : DiscourseDocumentGraph
        a document graph which contains RST annotations
    data : bool
        If True (default), yields (node ID, relation name, list of tokens)
        tuples. If False, yields just node IDs.
    rst_namespace : str
        The namespace that the RST annotations use (default: rst)

    Yields
    ------
    relations : str or (str, str, list of str) tuples
        If data=False, this will just yield node IDs of the nodes that
        directly dominate an RST relation. If data=True, this yields
        tuples of the form: (node ID, relation name, list of tokens that this
        relation spans).

def get_rst_relation_root_nodes(docgraph, data=True, rst_namespace='rst'):
    """
    yield all nodes that dominate one or more RST relations in the given
    document graph (in no particular order).

    Parameters
    ----------
    docgraph : DiscourseDocumentGraph
        a document graph which contains RST annotations
    data : bool
        If True (default), yields (node ID, relation name, list of tokens)
        tuples. If False, yields just node IDs.
    rst_namespace : str
        The namespace that the RST annotations use (default: rst)

    Yields
    ------
    relations : str or (str, str, list of str) tuples
        If data=False, this will just yield node IDs of the nodes that
        directly dominate an RST relation. If data=True, this yields
        tuples of the form: (node ID, relation name, list of tokens that this
        relation spans).
    """
    rel_attr = rst_namespace+':rel_name'
    for node_id, node_attrs in docgraph.nodes_iter(data=True):
        if rel_attr in node_attrs and node_attrs[rel_attr] != 'span':
            yield (node_id, node_attrs[rel_attr], get_span(docgraph, node_id)) \
                if data else (node_id)