Council social services bosses must think long and hard before trying to take severely-disabled children from the care of their parents, the most senior family court judge in England and Wales has warned.
Sir James Munby says parents may "justifiably resent" the launch of family court litigation in such circumstances.
He said if a very sick child was removed from home social workers had to "think very carefully" about ensuring that parents remained in "proper contact".
The judge said such children may not have long to live - and he said it would be "simply unbearable" to contemplate the reaction of parents unable to be with a dying child because of "bureaucracy".
Sir James, President of the Family Division of the High Court, has made a number of "observations" after analysing a case involving a council and the parents of a "profoundly neurologically disabled" four-year-old boy at a private family court hearing in London.
He said social services bosses had asked a judge to place the youngster in their care before changing their minds and agreeing that he could stay with his parents.
They had initially complained about the boy's parents being "rude and aggressive" towards medical staff.
They said the couple's lack of co-operation had made it "impossible" to implement a support package for the youngster. They had subsequently taken a different stance after saying the couple's behaviour had improved.
Sir James has not identified the little boy or the council involved in a written analysis of the case published on Tuesday.
"Cases such as this raise very complex issues," said Sir James.
"Local authorities need to think long and hard before embarking upon care proceedings against otherwise impeachable parents who may justifiably resent recourse to what they are likely to see as an unnecessarily adversarial and punitive remedy."
Sir James added: "If ... in a case such as this, a local authority is thinking of embarking upon care proceedings with a view, as here, to removing the child from the parents, it needs to think very carefully not merely about the practicalities of finding an appropriate placement, whether institutional or in a specialised foster placement, but also about the practicalities of ensuring that the parents have proper contact with their child during what may be its last few months or weeks of life."
He went on: "It is simply unbearable to contemplate the reaction of parents unable to be with their child at the moment of death because of geography or, even worse, bureaucracy."