def outgroup(tree, outgroups):
    """Root the provided tree by the provided outgroups, given that at least
    one of the outgroups are present within the tree and that the OTUs that are
    present are non-repetetive and form a monophyletic group. Returns the
    rooted tree and True if the conditions are met or the input tree and False
    if the conditions were not met.

    Parameters
    ----------
    tree : TreeNode object
        The node you wish to root.
    outgroups : list of strings
        Root the provided TreeNode object using the OTUs within this list.

    Returns
    -------
    tree : TreeNode object
        Tree rerooted at outgroups if conditions are met, input tree if not.
    rooted : bool
        True if conditions are met, False if not.
    """
    rooted = False
    outgroups_in_tree = tree.outgroups_present(outgroups)
    if not outgroups_in_tree:
        return tree, rooted
    if len(set(outgroups_in_tree)) < len(outgroups_in_tree):
        return tree, rooted
    if len(outgroups_in_tree) == 1:
        outgroup_otu = outgroups_in_tree[0]
        for leaf in tree.iter_leaves():
            otu = leaf.otu()
            if otu == outgroup_otu:
                rooted = True
                return tree.reroot(leaf), rooted
    for branch in tree.iter_branches():
        if branch.is_monophyletic_outgroup(outgroups_in_tree):
            rooted = True
            return tree.reroot(branch), rooted
    return tree, rooted
