def getSegments(nmlcell, component, sg_to_segments):
    """Get the list of segments the `component` is applied to"""
    sg = component.segmentGroup
    seg = component.segment
    if sg is None:
        if seg:
            segments = [seg]
        else:
            segments = nmlcell.morphology.segment
    elif sg == 'all':
        segments = [seg for seglist in sg_to_segments.values() for seg in
            seglist]
    else:
        segments = sg_to_segments[sg]
    return segments
