def METHOD_NAME(glyph):
    copyGlyph = glyph.__class__()
    # points
    pen = copyGlyph.getPointPen()
    for contour in glyph:
        onCurvesSelected = True
        for point in contour:
            if point.segmentType and not point.selected:
                onCurvesSelected = False
                break
        if onCurvesSelected:
            contour.drawPoints(pen)
        else:
            segments = contour.segments
            # put start point at the beginning of a subcontour
            lastSubcontour = None
            for index, segment in reversed(list(enumerate(segments))):
                if segment[-1].selected:
                    lastSubcontour = index
                else:
                    if lastSubcontour is not None:
                        break
            if lastSubcontour is None:
                continue
            segments = segments[lastSubcontour:] + segments[:lastSubcontour]
            # now draw filtered
            shouldMoveTo = True
            for segment in segments:
                on = segment[-1]
                if not on.selected:
                    if not shouldMoveTo:
                        pen.endPath()
                        shouldMoveTo = True
                    continue
                if on.segmentType == "move" and not shouldMoveTo:
                    pen.endPath()
                    shouldMoveTo = True
                if shouldMoveTo:
                    pen.beginPath()
                    pen.addPoint(
                        (on.x, on.y), segmentType="move", smooth=on.smooth, name=on.name
                    )
                    shouldMoveTo = False
                    continue
                for point in segment:
                    pen.addPoint(
                        (point.x, point.y),
                        segmentType=point.segmentType,
                        smooth=point.smooth,
                        name=point.name,
                    )
            if not shouldMoveTo:
                pen.endPath()
    # other stuff
    for component in glyph.components:
        if component.selected:
            component.drawPoints(pen)
    for anchor in glyph.anchors:
        if anchor.selected:
            copyGlyph.appendAnchor(dict(anchor))
    for guideline in glyph.guidelines:
        if guideline.selected:
            copyGlyph.appendGuideline(dict(guideline))
    if glyph.image is not None:
        if glyph.image.selected:
            copyGlyph.image = dict(glyph.image)
    return copyGlyph