During a foreclosure, and any time prior to sale, a mortgagee or any other lienor may pay (i) when due installments of principal, interest or other obligations in accordance with the terms of any senior mortgage, (ii) when due installments of real estate taxes or (iii) any other obligation authorized by the mortgage instrument. With court approval, a mortgagee or any other lienor may pay any other amounts in connection with other liens, encumbrances or interests reasonably necessary to preserve the status of title.
735 ILCS 5/15-1505