<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_if_not(cls, phases_or_groups):
 """Convert list of phases or groups into a new PhaseGroup if not already."""

    if isinstance(phases_or_groups, PhaseGroup):
      return mutablerecords.CopyRecord(phases_or_groups)

    flattened = flatten_phases_and_groups(phases_or_groups)
    return cls(main=flattened)