The court may examine the witnesses separately and may permit the petitioner, parent, guardian or other person entitled to the custody of a person deprived of his liberty, in person or by counsel, to examine publicly his alleged custodian as to the condition of such person and the place where he is detained or held in custody; and may also examine separately and apart, or publicly, such person, and may make orders for his release or permitting correspondence or personal interviews between him and his friends or relatives, and may modify its orders upon notice to the parties.
Mass. Gen. Laws ch. 248, § 38