The question arose in the case of trustees in a discretionary trust who had failed to make a distribution of benefits by mistake and then sought to remedy their mistake.
The Court made reference to a statement made by Lord Wilberforce in McPhail v Doulton  A.C. 424;  UKHL 1 where he explained how the court can act in such a matter:
“The Court, if called upon to execute the trust power, will do so in the manner best calculated to give effect to the settlor’s or testator’s intentions. It may do so by appointing new trustees, or by authorising or directing representative persons of the classes of the beneficiaries to prepare a scheme of distribution, or even, should the proper basis for distribution appear by itself directing the trustees to so distribute.
the transcript of McPhail v Doulton here.