If the land court shall find and determine, after hearing, that the enforcement of any of such restrictions or limitations would be injurious to the public interests, it shall register title to the land free from said restrictions as and to the extent required by the public interests, or, in case of registered land, shall enter an appropriate order therefor; provided, that if the land court shall find and determine that any of such restrictions or limitations, though they ought not to be enforced, are nevertheless valid and have not become inoperative, it shall, before registering said land free from said restrictions or limitations or any of them, ascertain and determine whether any person or property entitled to the benefits of any of such restrictions or limitations may be damaged by the non-enforcement thereof. If so, the case shall be referred to the superior court for the assessment of such damages. Chapter seventy-nine, so far as applicable, shall govern such assessment. The amount of any damages so assessed, with interest thereon from the date of such assessment to the date of payment at the rate allowed by law upon judgments, may be paid by the owner of the land into the superior court at any time after such assessment for the benefit of the persons or property entitled thereto; and, if so paid, the clerk of the superior court shall so certify to the land court, and shall pay the sum so received by him to the parties to whom it has been awarded. If no damages shall be awarded the clerk of the superior court shall certify that fact to the land court. Upon such certification from the clerk of the superior court of the final determination of such proceedings for assessment and of the payment of any damages therein assessed, the title may be registered free from any restrictions, or in case of registered land may be freed therefrom by the entry of such order as may be appropriate therefor.
Mass. Gen. Laws ch. 240, § 17