In any case where a Judge has to make a decision about what is best for a child, they can appoint a Guardian ad Litem (GAL) to represent the child's interests in the court or a Custody Investigator (CI) to provide information to the judge about the family situation. It is the responsibility of the GAL or CI to report to the Court what they believe is in the best interests of the child, regardless of what the parents, grandparents, or children think.
The Alaska Family law self help center describes Guardian ad Litems as:
A professional who is appointed to actually represent your child(ren) in the case. This means that he or she becomes a party to the case and may not always agree with the parents about what is in the child(ren)'s best interest. A GAL is different from a custody investigator, who simply does an investigation and makes a recommendation. See parenting plans for more information.
and Custody Investigators as:
A court appointed expert who is educated, experienced and trained in child development and the effects of divorce or separation on children. The custody investigator assesses a family and recommends to the judge a parenting plan that is in the best interests of the children. Check with your local court to learn how this program works in your community. See parenting plans for more information.