Factor out the common code in the transfer_leaf_tuples functions.