def METHOD_NAME(shape_or_compound):
    """compoundLeaves(shape_or_compound): extracts all non-compound shapes from a nested compound.
    Note: shape_or_compound may be a non-compound; then, it is the only thing in the
    returned list."""
    if shape_or_compound.ShapeType == "Compound":
        leaves = []
        for child in shape_or_compound.childShapes():
            leaves.extend( METHOD_NAME(child) )
        return leaves
    else:
        return [shape_or_compound]