(a) To the extent that a foundation is a charitable trust and one of its charitable purposes becomes impossible, impracticable, illegal, obsolete, ineffective, or prejudicial to the public interest to achieve, a court may apply cy pres for the following purposes:

(1) Modifying the foundation's certificate of formation or its bylaws; or

(2) Directing the foundation to apply or distribute some or all of its property to one or more charitable purposes that:

(A) Are useful to the community;

(B) Fulfills as nearly as possible the founder's charitable intent; and

(C) Do not violate any of the foundation's material purposes; or

(3) Terminating the foundation.

(b) Any of the following persons may commence a judicial proceeding seeking the application of cy pres to a foundation under this section:

(1) A foundation official;

(2) Unless the governing documents provide otherwise, a beneficiary; and

(3) The director of charitable trusts.