parameters: (list_of_shapes, types = None)
return_statement: return list_of_shapes
docstring: upgradeToAggregateIfNeeded(list_of_shapes, types = None): upgrades non-aggregate type
      shapes to aggregate-type shapes if the list has a mix of aggregate and non-aggregate
      type shapes. Returns the new list. Recursively traverses into compounds.
  
      aggregate shape types are Wire, Shell, CompSolid
      non-aggregate shape types are Vertex, Edge, Face, Solid
      Compounds are something special: they are recursively traversed to upgrade the
      contained shapes.
  
      Examples:
      list_of_shapes contains only faces -> nothing happens
      list_of_shapes contains faces and shells -> faces are converted to shells
  
      'types' argument is needed for recursive traversal. Do not supply.
docstring_summary: upgradeToAggregateIfNeeded(list_of_shapes, types = None): upgrades non-aggregate type
      shapes to aggregate-type shapes if the list has a mix of aggregate and non-aggregate
      type shapes. Returns the new list. Recursively traverses into compounds.
docstring_tokens: upgradeToAggregateIfNeeded ( list_of_shapes types = None ) : upgrades non - aggregate type shapes to aggregate - type shapes if the list has a mix of aggregate and non - aggregate type shapes . Returns the new list . Recursively traverses into compounds .
function: def upgradeToAggregateIfNeeded(list_of_shapes, types = None):
      """upgradeToAggregateIfNeeded(list_of_shapes, types = None): upgrades non-aggregate type
      shapes to aggregate-type shapes if the list has a mix of aggregate and non-aggregate
      type shapes. Returns the new list. Recursively traverses into compounds.
  
      aggregate shape types are Wire, Shell, CompSolid
      non-aggregate shape types are Vertex, Edge, Face, Solid
      Compounds are something special: they are recursively traversed to upgrade the
      contained shapes.
  
      Examples:
      list_of_shapes contains only faces -> nothing happens
      list_of_shapes contains faces and shells -> faces are converted to shells
  
      'types' argument is needed for recursive traversal. Do not supply."""
  
      import Part
      if types is None:
          types = set()
      for shape in list_of_shapes:
          types.add(shape.ShapeType)
          subshapes = compoundLeaves(shape)
          for subshape in subshapes:
              types.add(subshape.ShapeType)
      if "Wire" in types:
          list_of_shapes = [(Part.Wire([shape]) if shape.ShapeType == "Edge" else shape) for shape in list_of_shapes]
      if "Shell" in types:
          list_of_shapes = [(Part.Shell([shape]) if shape.ShapeType == "Face" else shape) for shape in list_of_shapes]
      if "CompSolid" in types:
          list_of_shapes = [(Part.CompSolid([shape]) if shape.ShapeType == "Solid" else shape) for shape in list_of_shapes]
      if "Compound" in types:
          list_of_shapes = [(Part.Compound(upgradeToAggregateIfNeeded(shape.childShapes(), types)) if shape.ShapeType == "Compound" else shape) for shape in list_of_shapes]
      return list_of_shapes
function_tokens: def upgradeToAggregateIfNeeded ( list_of_shapes , types = None ) : import Part if types is None : types = set ( ) for shape in list_of_shapes : types . add ( shape . ShapeType ) subshapes = compoundLeaves ( shape ) for subshape in subshapes : types . add ( subshape . ShapeType ) if "Wire" in types : list_of_shapes = [ ( Part . Wire ( [ shape ] ) if shape . ShapeType == "Edge" else shape ) for shape in list_of_shapes ] if "Shell" in types : list_of_shapes = [ ( Part . Shell ( [ shape ] ) if shape . ShapeType == "Face" else shape ) for shape in list_of_shapes ] if "CompSolid" in types : list_of_shapes = [ ( Part . CompSolid ( [ shape ] ) if shape . ShapeType == "Solid" else shape ) for shape in list_of_shapes ] if "Compound" in types : list_of_shapes = [ ( Part . Compound ( upgradeToAggregateIfNeeded ( shape . childShapes ( ) , types ) ) if shape . ShapeType == "Compound" else shape ) for shape in list_of_shapes ] return list_of_shapes