
487 N.W.2d 301 (1992)
Fredrick and Leona JANKE, Appellants,
v.
James R. CHACE et al., Appellees.
No. A-90-200.
Court of Appeals of Nebraska.
May 12, 1992.
*302 William R. Hadley and Robert J. Kirby, of Andersen, Berkshire, Lauritsen, Brower & Hadley, Omaha, for appellants.
Donald H. Bowman, Lincoln, for appellee Jack R. Chace.
Eileen L. McBride, Norfolk, for appellee Farm Credit Bank of Omaha.
Before SIEVERS, C.J., and HANNON and WRIGHT, JJ.
WRIGHT, Judge.
Fredrick and Leona Janke appeal from the decision of the district court for Stanton County denying their motion for marshaling of assets after the district court had entered a decree of foreclosure. We affirm the judgment as modified in accordance with this opinion.

SCOPE OF REVIEW
A foreclosure action is grounded in equity, and on appeal in such actions the Court of Appeals tries factual questions de novo on the record and reaches a conclusion independent of the findings of the trial court. Production Credit Assn. of the Midlands v. Schmer, 233 Neb. 749, 448 N.W.2d 123 (1989). See Neb.Rev.Stat. § 25-1925 (Supp.1991).
Where a situation exists which is contrary to the principles of equity and which can be redressed within the scope of judicial action, a court of equity will devise a remedy to meet the situation. Anderson v. Clemens Mobile Homes, 214 Neb. 283, 333 N.W.2d 900 (1983).
A court of equity which has acquired jurisdiction of a matter for any purpose will retain jurisdiction for the purpose of administering complete relief with respect to the subject matter. Hausner v. Melia, 212 Neb. 764, 326 N.W.2d 31 (1982).
Equity looks through forms to substance; a court of equity goes to the root of a matter and is not deterred by forms. Miller v. School Dist. No. 69, 208 Neb. 290, 303 N.W.2d 483 (1981).
Where a court dealing in equity has property or money under its jurisdiction, it has power to appropriately direct its application in order to carry out justice. Gatchell v. Henderson, 156 Neb. 1, 54 N.W.2d 227 (1952).

FACTS
The facts of this case are essentially undisputed. In 1969, the appellee Jack A. Chace purchased 280 acres of real estate and assumed a note and mortgage to appellee The Federal Land Bank of Omaha, now Farm Credit Bank of Omaha. On June 19, 1980, he sold 2 acres of this tract to his son, appellee James R. Chace, subject to Farm Credit Bank's mortgage. James Chace was married to plaintiff's daughter, Diana, and they borrowed $69,037.86 from Fredrick and Leona Janke to build a house on the 2 acres and executed a mortgage to the Jankes to secure repayment of the loan. Farm Credit Bank of Omaha held a first mortgage on the entire 280 acres, with Jack Chace as its debtor, and the Jankes held a second mortgage on the 2 acres, with James and Diana Chace as their debtors.
James and Diana Chace defaulted on the note to the Jankes, and the Jankes foreclosed against James Chace, which was interrupted *303 by his filing a chapter 7 bankruptcy. The Jankes obtained relief from the bankruptcy stay and obtained a decree of foreclosure. Diana Chace was not made a party to the foreclosure action.
On December 6, 1989, a foreclosure decree was entered in favor of the Jankes in the amount of $116,419.41 on their note and mortgage, and it was declared a valid second mortgage on the 2 acres of real estate owned by James Chace. Farm Credit Bank was found to hold a first mortgage position on the 2 acres described in the foreclosure decree, as well as on the 277 acres owned by Jack Chace. The first mortgage position held by Farm Credit Bank totaled $19,416.18. The evidence established the 277 acres owned by Jack Chace were valued at $178,345.
After entry of the decree of foreclosure on December 6, 1989, the Jankes requested the court to marshal the assets. The district court entered an order on February 2, 1990, denying the Jankes' application for marshaling of the assets.
If the assets were marshaled, the Jankes' second mortgage on the 2 acres would become, in effect, a first mortgage. If the assets were marshaled, the proceeds from the foreclosure sale would be paid to the Jankes. Without marshaling, the first $19,416.18 of sale proceeds would be applied to the debt of Jack Chace to Farm Credit Bank, with the remainder, if any, being paid to the Jankes.
The Jankes assert the district court erred in finding that the defendant Jack Chace had standing to oppose Jankes' application for marshaling, in failing to give proper effect to the stipulation between Farm Credit Bank and the Jankes, and in denying Jankes' application for marshaling. We discuss only the third assignment of error.
At the time the Jankes loaned money to their daughter, Diana, and son-in-law, James Chace, and took a note on the 2 acres, the first mortgage to Farm Credit Bank which secured the debt of Jack Chace was of record. What the Jankes sought to do in this case was subordinate the mortgage of Farm Credit Bank with respect to the proceeds from this foreclosure action, even though the Farm Credit Bank mortgage was of record at the time of their loan.
The root of the matter is what to do with the $19,416.18 debt that is owed by Jack Chace to Farm Credit Bank. It is clear that courts of equity may apply the doctrine of marshaling of assets in proper cases. Under the doctrine of marshaling of assets, if a senior lienor has a lien that extends to and covers two funds or potential funds and if the junior lienor has recourse to only one of those funds to satisfy the debt due him, the senior lienor may be required to exhaust the funds that are exclusively available to him before proceeding against the fund that is also available to the junior lienor. See In re Jack Green's Fashions for MenBig & Tall, 597 F.2d 130 (8th Cir.1979).
In the present case, Farm Credit Bank has two tracts of land as security for the debt owed by Jack Chace. The Jankes have security only on the 2 acres which is owned by James Chace. The debt of Jack Chace of $19,416.18 is secured by land valued at $178,345. However, the prerequisite for the application of the doctrine of marshaling of assets is the presence of a common debtor between the two creditors. That does not exist in this case. James Chace is the debtor of the Jankes, and Jack Chace is the debtor of Farm Credit Bank. Therefore, marshaling of assets is not appropriate. Although not involving the foreclosure of land but, rather, the replevin of a pickup, Platte Valley Bank of North Bend v. Kracl, 185 Neb. 168, 174 N.W.2d 724 (1970), held that the equitable doctrine of marshaling rested upon the basic principle that a senior creditor who has two funds from which he may satisfy his debt may not defeat a junior creditor who may resort to only one of these assets.
Kracl makes it clear that in order to marshal the assets, both funds must be in the hands of a common debtor of both creditors. 55 C.J.S. Marshaling Assets and Securities § 6 (1948). Marshaling will not be applied where the parties themselves have by contract fully defined their *304 rights with reference to the priority of the marshaling of their assets. Marshaling will not be permitted if it would hinder or impose hardship on the paramount creditor, inconvenience him in the collection of his debt, or deprive him of his rights under the contract. Marshaling will be denied if final satisfaction to the paramount creditor is uncertain or where the effect of applying the doctrine will be to compel the paramount creditor to proceed by an independent action, such as one for the foreclosure of a mortgage, since that will place an additional burden on the paramount creditor. It is the paramount creditor that cannot be prejudiced. Kracl, supra.
Were we to stop here, the result might be technically correct that marshaling the assets is not available as a remedy to the Jankes, but the result would be patently unfair and unjust. The parties to the case readily admit that the matter is heard by the court in equity and that the court has before it all the parties and has proper jurisdiction. Where a court dealing in equity has property or money under its jurisdiction, it has power to appropriately direct its application in order to carry out justice. Gatchell v. Henderson, 156 Neb. 1, 54 N.W.2d 227 (1952). In Gatchell, the effect of the judgment was nevertheless to conclude that plaintiff did not have a timely filed mechanic's lien or right to a personal judgment against the owners, but that he should have a lien upon $322.19, the balance of money concededly owing by the owners to the contractor, despite the fact that they could have paid any part or all of it to the contractor with safety and that the contractor was concededly then indebted to such owners in the amount of $240 for breach of contract.
Although distinguishable on the facts, the Gatchell court's willingness to apply equitable principles in order to obtain justice is readily apparent. The court applied the rule that ordinarily an owner has a right to offset damages for breach of contract against any sum of money due on his building contract with the contractor. "To refuse to apply such a rule ... would require the innocent owners, who were guilty of no wrong whatever, to pay plaintiff $322.19 when there was no liability to him therefor or for any other amount [and] was neither justice or equity." Gatchell, 156 Neb. at 11, 54 N.W.2d at 233.
To require the Jankes to pay $19,416.18 to Jack Chace via the debt to Farm Credit Bank would be neither justice nor equity. "'"Equity will devise a remedy to meet emergencies, and will adjust the property interests of litigants whenever it can do so without prejudice to the legal or equitable rights of any person."'" Id., quoting Penn Mutual Life Ins. Co. v. Katz, 139 Neb. 501, 297 N.W. 899 (1941). The paramount question, "Why should the Jankes pay Jack Chace's debt to Farm Credit Bank?" has not been answered by the appellees.
The parties to this litigation previously defined their rights with reference to the priority of the assets by contract. The mortgage the Jankes foreclosed against James Chace was executed on June 4, 1984, and filed 2 days later with the register of deeds of Stanton County. However, the real estate mortgage covering the entire 280 acres in favor of Farm Credit Bank was dated November 28, 1967, in the amount of $28,500, and recorded with the register of deeds of Stanton County on November 29, 1967. When the Jankes made the loan to James Chace, they knew, or should have known, that they were in a secondary position behind Farm Credit Bank. The financial risk they took by being in a secondary position should have been obvious to them. But the Jankes' failure to obtain a subordination from Farm Credit Bank does not justify their payment of Jack Chace's debt.
Equity will not permit us to prejudice the rights of Farm Credit Bank, which clearly did nothing but establish its rights by contractual agreement of record. Equity will also not permit us to require the Jankes to pay the debt of Jack Chace to Farm Credit Bank without imposing upon Chace some obligation to repay the debt to the Jankes. The basis for allowing relief to the Jankes was stated in Redding v. Gibbs, 203 Neb. 727, 738-29, 280 N.W.2d 53, 60 (1979), quoting *305 Justice Cardozo's dissenting opinion in Graf v. Hope Building Corp., 254 N.Y. 1, 171 N.E. 884 (1930):
"True, indeed, it is that accident and mistake will often be inadequate to supply a basis for the granting or withholding of equitable remedies where the consequences to be corrected might have been avoided if the victim of the misfortune had ordered his affairs with reasonable diligence.... The restriction, however, is not obdurate, for always the gravity of the fault must be compared with the gravity of the hardship.... Let the hardship be strong enough, and equity will find a way, though many a formula of inaction may seem to bar the path...."
In the present case, the court was technically correct in denying the Jankes' request to marshal the assets. This could prejudice an innocent party, Farm Credit Bank, but would create an undeserved windfall in favor of Jack Chace at a cost of $19,416.18 to the Jankes. The gravity of the fault of the Jankes must be weighed against the gravity of the hardship. Having obtained jurisdiction of the subject matter and the parties, a court of equity will retain it for all purposes and render such judgment as will protect the rights of the parties before it. Hausner v. Melia, 212 Neb. 764, 326 N.W.2d 31 (1982). This is an action in equity, and the law requires the court on appeal to try the factual questions de novo on the record and reach an independent conclusion without reference to the findings of the trial court. Production Credit Assn. of the Midlands v. Schmer, 233 Neb. 749, 448 N.W.2d 123 (1989).
The facts are essentially undisputed, and the following principles control the decision in this case: Having properly acquired jurisdiction in a matter for equitable relief, the court may make a complete adjudication of all matters properly presented and involved in the case and grant relief, legal or equitable, as may be required and thus avoid unnecessary litigation. Miller v. School Dist. No. 69, 208 Neb. 290, 303 N.W.2d 483 (1981). When equity once acquires jurisdiction, it will retain it so as to afford complete relief. Miller, supra; Hardt v. Orr, 142 Neb. 460, 6 N.W.2d 589 (1942). "`Equity looks through forms to substance,' or as stated in similar language, `A court of equity goes to the root of a matter and is not deterred by forms.'" Darnell v. City of Broken Bow, 139 Neb. 844, 854, 299 N.W. 274, 281 (1941).
The court in Anderson v. Clemens Mobile Homes, 214 Neb. 283, 333 N.W.2d 900 (1983), held that where a situation exists which is contrary to the principles of equity and which can be redressed within the scope of judicial action, a court of equity will devise a remedy to meet the situation.
Having concluded that equitable principles require that the court devise a remedy to meet the situation, we direct that the debt of Jack Chace, as evidenced by the note assumed by him pursuant to an agreement entitled "Assumption Agreement and Notice of Change of Ownership," dated March 18, 1969, and the mortgage securing the same duly recorded in book 64, page 203, of the mortgage records of Stanton County, Nebraska, in the amount of $19,416.18 as per the decree of the district court dated December 21, 1989, plus accrued interest shall be paid to Farm Credit Bank of Omaha from the proceeds of the foreclosure sale. Upon said payment, Farm Credit Bank shall sell, convey, transfer, and assign to Fredrick and Leona Janke all of its right, title, and interest in the note and mortgage on said real estate.
Fredrick and Leona Janke, upon assignment of said mortgage, are authorized to subordinate said mortgage to their mortgage duly recorded on June 6,1984, in book 72, page 526, of the mortgage records of Stanton County, Nebraska, so as to be able to convey said 2 acres free and clear of the existing mortgage of Farm Credit Bank of Omaha. They shall apply the proceeds of the foreclosure first to the payment of the note to Farm Credit Bank, as described above, and the remaining proceeds shall be applied as set forth in the decree of the district court dated December 21, 1989.
AFFIRMED AS MODIFIED.
