There would be a closing at which the settlement sheet would credit the outstanding balance on the obligation secured by the deed of trust against the purchase price.
The beneficiary of the deed of trust would execute a release of the deed of trust, and the owner of the property would execute a deed to the beneficiary of the deed of trust.
Strictly speaking, a deed from the owner to the beneficiary might extinguish the deed of trust anyway due to the doctrine of merger and if there was a desire to keep the deed of trust with the priority it affords to the lender in place, the owner might convey not to the beneficiary of the deed of trust but to another entity related to and owned by the beneficiary.
Conceptually, for the most part, deeds of trust are conceived of as mortgages with a lien theory (which was invented in California), in modern commerce, whatever the legal fictions associated with the deed of trust concept at its inception originally imagined.
A lengthy scholarly treatment of the questions you are asking can be found in this law review article from the California Law Review in July of 1915, but it is (obviously) out of date.