@classmethod
def getSegmentsList(cls, workOrPart, removeEmptyLists=True):
    """
        Segments a part by its rests (and clefs) and returns a returns a list of lists where
        each sublist is one segment of contiguous notes. NB Uses .recurse() internally.

        >>> testStream = converter.parse("tinyNotation: C4 r D E r r F r G r A B r c")
        >>> segments = analysis.segmentByRests.Segmenter.getSegmentsList(testStream)
        >>> segments
        [[<music21.note.Note C>],
         [<music21.note.Note D>, <music21.note.Note E>],
         [<music21.note.Note F>],
         [<music21.note.Note G>],
         [<music21.note.Note A>, <music21.note.Note B>],
         [<music21.note.Note C>]]
        """
    segments = []
    thisSegment = []
    partNotes = workOrPart.recurse().getElementsByClass(['Note', 'Rest',
        'Clef'])
    for i in range(len(partNotes)):
        n = partNotes[i]
        if 'Note' in n.classes:
            thisSegment.append(n)
            if i == len(partNotes) - 1:
                segments.append(thisSegment)
        if 'Rest' in n.classes or 'Clef' in n.classes:
            segments.append(thisSegment)
            thisSegment = []
            continue
    if removeEmptyLists:
        for segment in segments[::-1]:
            if not segment:
                segments.remove(segment)
    return segments
