When marriages and other unions that produce children break up, determining who gets custody of the kids can be a major sticking point. Some parents go as far as trying to denigrate the other parent by calling them unfit to rear their children.
Over time, the family law courts have evolved from the presumption that the mother is the de facto caretaker of the children to what is in the children's best interests. In most cases, unless there are significant issues that prevent co-parenting, the courts will award joint custody to the parents.
Even when joint custody is the outcome, it's possible that one parent will be granted more time with the kids for practical reasons. It may be that it's better for the children to live with the parent who remains in their school district. Or perhaps one parent's swing-shift work schedule makes daily parenting too great of an obstacle.
To declare either parent unfit requires proof that the parent was abusive, neglectful, had an untreated mental illness or had a substance abuse problem. To that end, parents who seek treatment and stay on their medications and/or avoid drugs or alcohol would not necessarily be viewed as unfit.
Older children can be permitted to convey their preferences about where they live to the court. Even then, if the preferred parent can't adequately meet their children's needs, it's not likely that a court would award primary custody to that parent.
It's more difficult than many people imagine to get a parent declared unfit, and that may be a good thing. It's important to always remember that your children love their other parent and that should be respected.