In the case of a trust which is not exempt from tax under section
501
(a), not all of the unexpired interests in which are devoted to one or more of the purposes described in section
170
(c)(2)(B), and which has amounts in trust for which a deduction was allowed under section
170,
545
(b)(2),
642
(c),
2055,
2106
(a)(2), or
2522, section
507 (relating to termination of private foundation status), section
508
(e) (relating to governing instruments) to the extent applicable to a trust described in this paragraph, section
4941 (relating to taxes on self-dealing), section
4943 (relating to taxes on excess business holdings) except as provided in subsection (b)(3), section
4944 (relating to investments which jeopardize charitable purpose) except as provided in subsection (b)(3), and section
4945 (relating to taxes on taxable expenditures) shall apply as if such trust were a private foundation. This paragraph shall not apply with respect to—