protected bool CheckSegmentType(Segment segment, char type) { if (segment == null) return false; return segment.type == type; }