(b)may direct payment to the vendor or lessor of all the rents and profits which have accrued in respect of the property from the date on which possession was so obtained by the purchaser or lessee until restoration of possession to the vendor or lessor, and if the justice of the case so requires, the refund of any sum paid by the vendee or lessee as earnest money or deposit in connection with the contract.