def fuzzy_match_tipnames(ttree, names, wildcard, regex, mrca=True, mono=True):
<EOL>if not any([names, wildcard, regex]):<EOL><INDENT>raise ToytreeError(<EOL>"<STR_LIT>")<EOL><DEDENT>tips = []<EOL>if names:<EOL><INDENT>if isinstance(names, (str, int)):<EOL><INDENT>names = [names]<EOL><DEDENT>notfound = [i for i in names if i not in ttree.get_tip_labels()]<EOL>if any(notfound):<EOL><INDENT>raise ToytreeError(<EOL>"<STR_LIT>".format(notfound))<EOL><DEDENT>tips = [i for i in ttree.treenode.get_leaves() if i.name in names]<EOL><DEDENT>elif regex:<EOL><INDENT>tips = [<EOL>i for i in ttree.treenode.get_leaves() if re.match(regex, i.name)<EOL>]               <EOL>if not any(tips):<EOL><INDENT>raise ToytreeError("<STR_LIT>")<EOL><DEDENT><DEDENT>elif wildcard:<EOL><INDENT>tips = [i for i in ttree.treenode.get_leaves() if wildcard in i.name]<EOL>if not any(tips):<EOL><INDENT>raise ToytreeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if not tips:<EOL><INDENT>raise ToytreeError("<STR_LIT>")       <EOL><DEDENT>tipnames = [i.name for i in tips]<EOL>if len(tips) == <NUM_LIT:1>:<EOL><INDENT>if mrca:<EOL><INDENT>return tips[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return tipnames<EOL><DEDENT><DEDENT>mbool, mtype, mnames = (<EOL>ttree.treenode.check_monophyly(<EOL>tipnames, "<STR_LIT:name>", ignore_missing=True)<EOL>)<EOL>node = ttree.treenode.get_common_ancestor(tips)<EOL>if mono:<EOL><INDENT>if not mbool:<EOL><INDENT>raise ToytreeError(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>if not mrca:<EOL><INDENT>return tipnames<EOL><DEDENT>else:<EOL><INDENT>return node<EOL><DEDENT>
Used in multiple internal functions (e.g., .root()) and .drop_tips())
to select an internal mrca node, or multiple tipnames, using fuzzy matching
so that every name does not need to be written out by hand.

name: verbose list
wildcard: matching unique string
regex: regex expression
mrca: return mrca node of selected tipnames. 
mono: raise error if selected tipnames are not monophyletic