Can mother lose custody if she is mentally ill?

Whether or not a mother can lose custody is up to a judge. Judges have the task of establishing custody.