Section 27E. Any party on whose behalf any fees or costs have been waived or paid by the commonwealth pursuant to sections twenty-seven C or twenty-seven F, or both, shall repay the total amount thereof to the clerk or register of the court if said party shall have recovered, as a result of the proceeding in which said fees or costs were waived or paid, an amount in excess of three times the total amount of said fees and costs. In any case in which any fees or costs have been so waived or paid, the court, upon the waiver or payment of any such fees or costs shall notify all parties of the total amount of said fees and costs to date and that any money judgment or settlement in favor of the party for whom said fees or costs were waived or paid which exceeds three times the total amount thereof shall be deposited with the clerk or register of the court in the following manner. Any party obligated to pay any judgment or settlement exceeding three times the total amount of said fees and costs, or any portion of such a judgment or settlement, shall pay to the clerk or register the total amount of said fees or costs, or if more than one party is so obligated, his proportional share thereof, and deduct the same from such judgment or settlement. The clerk or register shall notify all parties when the total amount of fees and costs has been so reimbursed. When said notification is received by the party obligated to pay such judgment or settlement or portion thereof, or if no such notification is received after the expiration of thirty days after the payment by said party of such fees or costs or his share thereof, said party shall promptly forward the remainder of the judgment or settlement to the party entitled to it. This procedure shall not be construed to excuse any person on whose behalf any fees or costs have been waived or paid from the obligation to repay the same as provided in this section.