Section 15. (a) If the record title of land or of easements or rights in land is encumbered by an undischarged mortgage or a mortgage not properly or legally discharged of record, and a mortgagor or a mortgagor's heirs, successors or assigns claim that the mortgage has been fully paid or the conditions or obligations secured thereby have been fully satisfied and that the holder of the mortgage has neglected or refused to provide a discharge in accordance with section 55 of chapter 183, the mortgagor, the mortgagor's heirs, successors or assigns, or any person exercising the rights in easements, or any person named in section 11, may file a petition in the land court or, except in the case of registered land, in the superior court for the county in which the land is located; and if, after such notice by publication or otherwise, as the court orders, the court finds on a preponderance of the evidence that the mortgage has been fully paid or satisfied and that the mortgage ought to be discharged, it shall enter a decree discharging the mortgage, which decree, when duly recorded in the registry of deeds for the county or district where the land lies or, in the case of registered land, when duly noted on the memorandum of encumbrances of the relevant certificate of title, shall operate as a discharge of the mortgage and no action to enforce a title under the mortgage shall thereafter be maintained.
(b) If the record title of land or of easements or rights in land is encumbered by an undischarged mortgage or a mortgage not properly or legally discharged of record, and the mortgagor or the mortgagor's heirs, successors or assigns do not have actual or direct evidence of full payment or satisfaction of the mortgage but the mortgagor, or the mortgagor's heirs, successors or assigns have been in uninterrupted possession of the land or exercising the rights in easements or other rights in the land, either: (1) in the case of a successor or assign who is a bona fide purchaser for value or who is an heir, successor or assign of the bona fide purchaser for value, for any period of 1 year after the expiration of the time limited in the mortgage for the full performance of the condition thereof, or for any period of 20 years after the recording of a deed from the mortgagor or his heirs or devisees to the bona fide purchaser, which deed did not evidence that title was taken subject to the mortgage or that the purchaser assumed or agreed to pay the mortgage; or (2) in the case of the mortgagor, or the mortgagor's heirs, devisees or successors by operation of law, for any period of 1 year after the expiration of the time limited in the mortgage for the full performance of the condition thereof, or for any period of 20 years after the date of a mortgage not given to secure the payment of money or a debt but to secure the mortgagee against a contingent liability which has so ceased to exist that no person will be prejudiced by the discharge thereof, the mortgagor, or the mortgagor's heirs, successors or assigns, or any person exercising the rights in easements or any person named in section 11, may file a petition in the land court or, except in the case of registered land, in the superior court for the county in which the land is located; and if, after such notice by publication or otherwise as the court orders, no evidence is offered of a payment on account of the debt secured by the mortgage within the relevant period of uninterrupted possession or of any other act within the time in recognition of its existence as a valid mortgage, or if the court finds that the contingent liability has ceased to exist and that the mortgage ought to be discharged, it may enter a decree discharging the mortgage, which decree, when duly recorded in the registry of deeds for the county or district where the land lies or, in the case of registered land, when duly noted on the memorandum of encumbrances of the relevant certificate of title, shall operate as a discharge of said mortgage and no action to enforce a title under the mortgage shall thereafter be maintained. Two or more persons owning in severalty different portions or different interests, such as are described in section 11, in the land subject to the mortgage may join in 1 petition, and 2 or more defects arising under different mortgages affecting 1 parcel of land may be set forth in the same petition. If the petition is contested, the court shall make an appropriate order for separate issues.