Every person imprisoned or otherwise restrained of his or her liberty, except as herein otherwise provided, may apply for habeas corpus in the manner provided in X of this Act, to obtain relief from such imprisonment or restraint, if it prove to be unlawful.
735 ILCS 5/10-102