Any person with mental illness, serious emotional disturbance, or developmental disability in a public or private residential facility for persons with mental illness, serious emotional disturbance, or developmental disability is entitled to file for a writ of habeas corpus upon petition by the person with mental illness, serious emotional disturbance, or developmental disability or a friend to any court generally empowered to issue the writ of habeas corpus in the county in which the person with mental illness, serious emotional disturbance, or developmental disability is detained.