(a) The trustee may avoid a lien that secures a claim of a kind specified in section 726 (a)(4) of this title.
(b) Property in which the estate has an interest and that is subject to a lien that is not avoidable under this title (other than to the extent that there is a properly perfected unavoidable tax lien arising in connection with an ad valorem tax on real or personal property of the estate) and that secures an allowed claim for a tax, or proceeds of such property, shall be distributed—
(1) first, to any holder of an allowed claim secured by a lien on such property that is not avoidable under this title and that is senior to such tax lien;
(2) second, to any holder of a claim of a kind specified in section 507 (a)(1)(C) or 507 (a)(2) (except that such expenses under each such section, other than claims for wages, salaries, or commissions that arise after the date of the filing of the petition, shall be limited to expenses incurred under this chapter and shall not include expenses incurred under chapter 11 of this title), 507(a)(1)(A), 507(a)(1)(B), 507(a)(3), 507(a)(4), 507(a)(5), 507(a)(6), or 507(a)(7) of this title, to the extent of the amount of such allowed tax claim that is secured by such tax lien;
(3) third, to the holder of such tax lien, to any extent that such holder’s allowed tax claim that is secured by such tax lien exceeds any amount distributed under paragraph (2) of this subsection;
(4) fourth, to any holder of an allowed claim secured by a lien on such property that is not avoidable under this title and that is junior to such tax lien;
(5) fifth, to the holder of such tax lien, to the extent that such holder’s allowed claim secured by such tax lien is not paid under paragraph (3) of this subsection; and
(6) sixth, to the estate.
(c) If more than one holder of a claim is entitled to distribution under a particular paragraph of subsection (b) of this section, distribution to such holders under such paragraph shall be in the same order as distribution to such holders would have been other than under this section.
(d) A statutory lien the priority of which is determined in the same manner as the priority of a tax lien under section 6323 of the Internal Revenue Code of 1986 shall be treated under subsection (b) of this section the same as if such lien were a tax lien.
(e) Before subordinating a tax lien on real or personal property of the estate, the trustee shall—
(1) exhaust the unencumbered assets of the estate; and
(2) in a manner consistent with section 506 (c), recover from property securing an allowed secured claim the reasonable, necessary costs and expenses of preserving or disposing of such property.
(f) Notwithstanding the exclusion of ad valorem tax liens under this section and subject to the requirements of subsection (e), the following may be paid from property of the estate which secures a tax lien, or the proceeds of such property:
(1) Claims for wages, salaries, and commissions that are entitled to priority under section 507 (a)(4).
(2) Claims for contributions to an employee benefit plan entitled to priority under section 507 (a)(5).