I'm going to add a docstring here, like:
```python
    """
    Reroot a tree by minimizing the number of duplications/losses/both

    Note that rootby trumps dupcost/losscost.
    gtree -- gene tree to reroot
    stree -- species tree
    gene2species -- mapping from gene names to species names
    rootby -- method to root by ("dup", "loss", "duploss")
    returnCost -- if True, also return event cost of rerooted gene tree
    dupcost -- cost of gene duplication
    losscost -- cost of gene loss
    keepName -- if True, reuse existing root name for new root node
    """
```