def METHOD_NAME(root: ZcashMMRNode, leaf: ZcashMMRNode) -> ZcashMMRNode:
    '''Append a leaf to an existing tree, return the new tree root'''
    # recursively find a list of peaks in the current tree
    peaks: List[ZcashMMRNode] = get_peaks(root)
    merged: List[ZcashMMRNode] = []
    # Merge peaks from right to left.
    # This will produce a list of peaks in reverse order
    current = leaf
    for peak in peaks[::-1]:
        current_leaves = current.nLatestHeight - (current.nEarliestHeight - 1)
        peak_leaves = peak.nLatestHeight - (peak.nEarliestHeight - 1)
        if current_leaves == peak_leaves:
            current = make_parent(peak, current)
        else:
            merged.METHOD_NAME(current)
            current = peak
    merged.METHOD_NAME(current)
    # finally, bag the merged peaks
    return bag_peaks(merged[::-1])