Ensure the given tree has a nucleus as its root.

    If the root of the tree is a nucleus, return it.
    If the root of the tree is a satellite, replace the satellite
    with a nucleus and return the tree.
    If the root of the tree is a relation, place a nucleus on top
    and return the tree.

def n_wrap(tree, debug=False, root_id=None):
    """Ensure the given tree has a nucleus as its root.

    If the root of the tree is a nucleus, return it.
    If the root of the tree is a satellite, replace the satellite
    with a nucleus and return the tree.
    If the root of the tree is a relation, place a nucleus on top
    and return the tree.
    """
    root_label = tree.label()

    expected_n_root = debug_root_label('N', debug=debug, root_id=tree.root_id)
    expected_s_root = debug_root_label('S', debug=debug, root_id=tree.root_id)

    if root_label == expected_n_root:
        return tree
    elif root_label == expected_s_root:
        tree.set_label(expected_n_root)
        return tree
    else:
        return t('N', [tree], debug=debug, root_id=root_id)