code: def _get_top_level_images(imagedata, subset=None):
      '''
      Returns a list of the top-level images (those which are not parents). If
      ``subset`` (an iterable) is passed, the top-level images in the subset will
      be returned, otherwise all top-level images will be returned.
      '''
      try:
          parents = [imagedata[x]['ParentId'] for x in imagedata]
          filter_ = subset if subset is not None else imagedata
          return [x for x in filter_ if x not in parents]
      except (KeyError, TypeError):
          raise CommandExecutionError(
              'Invalid image data passed to _get_top_level_images(). Please '
              'report this issue. Full image data: {0}'.format(imagedata)
          f _get_top_level_images(imagedata, subset=None):
      '''
      Returns a list of the top-level images (those which are not parents). If
      ``subset`` (an iterable) is passed, the top-level images in the subset will
      be returned, otherwise all top-level images will be returned.
      '''
      try:
          parents = [imagedata[x]['ParentId'] for x in imagedata]
          filter_ = subset if subset is not None else imagedata
          return [x for x in filter_ if x not in parents]
      except (KeyError, TypeError):
          raise CommandExecutionError(
              'Invalid image data passed to _get_top_level_images(). Please '
              'report this issue. Full image data: {0}'.format(imagedata)
          )
docs: Returns a list of the top-level images (those which are not parents). If
      ``subset`` (an iterable) is passed, the top-level images in the subset will
      be returned, otherwise all top-level images will be returned.