The procedure is typically done under sedation or general anesthesia to ensure the child's comfort. The endoscope is gently inserted through the mouth (for upper GI endoscopy) or the rectum (for lower GI endoscopy). The doctor can visually inspect the gastrointestinal tract and take tissue samples if necessary. These biopsies are then examined under a microscope to identify any abnormalities.