When children are young, they lack the experience and mental capacity to make important decisions about their lives. That job should be left to their parents or, if necessary, a family law judge.

But as kids age, their ability to explain their desires increase, and New York courts know this. When teenagers and older children are caught in the middle of a child custody dispute, the court may allow them to testify, so that if they prefer to live with one parent over the other, the judge will take that into consideration.

In a high-profile example, television host Bill O’Reilly has lost custody of his teenage children to his former wife, after the children said they no longer wanted to live with him. A court of appeals affirmed the lower court ruling that changed the child custody arrangement from split custody to sole custody for the mother.

In the ruling, the appellate court relied largely on “the clearly stated preferences of the children, especially considering their age and maturity,” Gawker reports. The court also noted that the children’s mother provides a good home environment, compared to the home O’Reilly provided. Previously, in an interview with a forensic examiner, the older child said she once witnessed O’Reilly physically abusing her mother, and called O’Reilly a distant and often absent father.

It can be very difficult for children to decide which parent to live with, and their stated preferences are not the only factor to consider. As always, the children’s best interests are the court’s top priority.