Senior judges have raised concerns about a case in which a 71-year-old grandmother was given a six-month jail term after social services bosses complained she had breached orders made in the Court of Protection.
Teresa Kirk, of Brighton, East Sussex, was freed last month after an appeal.
Three Court of Appeal judges on Monday outlined their reasons for ruling that she should go free.
They said the "circumstances of the case" were of "significant concern".
Mrs Kirk was jailed in August following a Court of Protection hearing in London at which judge Mr Justice Newton concluded she was in contempt of court.
Lawyers representing Devon County Council had told Mr Justice Newton how social services bosses had responsibility for an elderly man.
They complained that Mrs Kirk had taken the man to a care home in his native Portugal and, in breach of a judge's orders, had refused to return him to England.
Mr Justice Newton said the man could not be identified.
The judge's written ruling on the case did not spell out the relationship between the man and Mrs Kirk.
But appeal judges said Mrs Kirk's challenge to Mr Justice Newton's "committal order" had to succeed.
"I am bound to record that I find the circumstances of this case to be of significant concern," said one appeal judge, Lord Justice McFarlane.
"The Court of Protection has sentenced a 71-year-old lady to prison in circumstances where the lady concerned is said to be of previous good character and ... has been acting on the basis of deeply held, sincere beliefs as to the interests of (the elderly man) for whose welfare she is ... genuinely concerned."
The two other appeal judges, Lady Justice Black and Sir James Munby, agreed.
Sir James, the President of the Court of Protection - and most senior Court of Protection judge in England and Wales, said he shared the concerns outlined by Lord Justice McFarlane.
Appeal judges, who analysed the case at a hearing in London, said Devon council social services bosses had begun litigation in the Court of Protection - where judges consider issues relating to people who lack the mental capacity to make decisions - more than two years ago.
They said they elderly man at the centre of the case was now 81.
He had dementia and had signed a "power of attorney" giving Mrs Kirk and another person permission to manage his affairs.
Appeal judges said he had lived in Devon for many years but was originally from Madeira - where some of his relatives still lived.
In 2015 an independent social worker had concluded that the man should live in a care facility near his Devon home.
Shortly afterwards, Mrs Kirk had moved him to a care home in Portugal.
Mrs Kirk had subsequently been ordered by a judge to "cause" the man's return to England.
Appeal judges said it was "common ground" that Mrs Kirk had failed to comply with an order and the man remained in a Portuguese care home.
They said Mr Justice Newton had "no option" but to conclude that she was in contempt of court.
She had been given a six-month term. The term was initially suspended.
But she had been arrested on September 26 and released when her appeal was allowed on November 8.
Appeal judges praised barrister Colin Challenger who had represented Mrs Kirk for free.
Mr Challenger had said Mrs Kirk had been treated unfairly and mounted 13 grounds of appeal.
Lord Justice McFarlane said Mr Challenger's conduct was "worthy of significant praise".
Sir James had said during the appeal hearing that Mrs Kirk had been "failed by the system".
"Of greatest concern ... is the fact that, in circumstances where she should never have been committed at all, Mrs Kirk languished in prison for almost seven weeks before being released," Sir James added in the ruling.
"How much longer might she have remained there had Mr Challenger not intervened and been so tenacious in his pursuit of her release?"
He added: "A proper system should not permit this to happen. The fact that it did happen here suggests that the systems in place are not adequate."
Copyright (c) Press Association Ltd. 2016, All Rights Reserved.