code: def _merge_flags(new_flags, old_flags=None, conf='any'):
      '''
      Merges multiple lists of flags removing duplicates and resolving conflicts
      giving priority to lasts lists.
      '''
      if not old_flags:
          old_flags = []
      args = [old_flags, new_flags]
      if conf == 'accept_keywords':
          tmp = new_flags + \
              [i for i in old_flags if _check_accept_keywords(new_flags, i)]
      else:
          tmp = portage.flatten(args)
      flags = {}
      for flag in tmp:
          if flag[0] == '-':
              flags[flag[1:]] = False
          else:
              flags[flag] = True
      tmp = []
      for key, val in six.iteritems(flags):
          if val:
              tmp.append(key)
          else:
              tmp.append('-' + key)
  
      # Next sort is just aesthetic, can be commented for a small performance
      # boost
      tmp.sort(key=lambda x: x.lstrip('-'))
      return tmf _merge_flags(new_flags, old_flags=None, conf='any'):
      '''
      Merges multiple lists of flags removing duplicates and resolving conflicts
      giving priority to lasts lists.
      '''
      if not old_flags:
          old_flags = []
      args = [old_flags, new_flags]
      if conf == 'accept_keywords':
          tmp = new_flags + \
              [i for i in old_flags if _check_accept_keywords(new_flags, i)]
      else:
          tmp = portage.flatten(args)
      flags = {}
      for flag in tmp:
          if flag[0] == '-':
              flags[flag[1:]] = False
          else:
              flags[flag] = True
      tmp = []
      for key, val in six.iteritems(flags):
          if val:
              tmp.append(key)
          else:
              tmp.append('-' + key)
  
      # Next sort is just aesthetic, can be commented for a small performance
      # boost
      tmp.sort(key=lambda x: x.lstrip('-'))
      return tmp
docs: Merges multiple lists of flags removing duplicates and resolving conflicts
      giving priority to lasts lists.