Firstly, it is in my view a responsibility of parents who separate to make reasonable efforts to ensure that a good relationship is maintained between both parents and children. There are circumstances under which this is obviously not reasonable (when one of the parents is a real threat to the children). However, this is clearly a responsibility.
However, the objective of maintaining contact between parent and child does not permit the court to behave unlawfully. There are a number of problems with this case. The first is that the court should not ordinarily hear a contempt hearing of its own motion. The second hearing (and the third) should have been held by a different judge to the one who heard it. The second is that legal assistance should have been made available before the grandparents and aunt were locked up on bail.
It raises a question really as to whether effectively a form of collective punishment was being used to encourage the mother to make contact with the court.
I don't take the view that the ends (which I agree with about ensuring contact) justify the means.