Returns the type of the root node of the given RST tree
    (one of 'N', 'S', 'relation' or 'edu'.)

def get_node_type(tree):
    """Returns the type of the root node of the given RST tree
    (one of 'N', 'S', 'relation' or 'edu'.)
    """
    if isinstance(tree, (RSTTree, nltk.tree.Tree)):
        if tree.label() in ('N', 'S'):
            return tree.label()
        else:
            return 'relation'
    elif isinstance(tree, basestring):
        return 'edu'
    else:
        raise ValueError("Unknown tree/node type: {}".format(type(tree)))