If the plaintiff has had judgment for seisin of the land, he may take out a writ of seisin before judgment has been rendered upon his claim for rents and profits or other damages or upon the defendant's counterclaim for improvements, but if there is pending such a counterclaim, the plaintiff, before taking out his writ of seisin, shall furnish such security or pay into court such amount of money as the land court may order, to secure to the defendant the payment of any amount found due him for such improvements.
Mass. Gen. Laws ch. 237, § 29