code: def filter_unique_peptides(peptides, score, ns):
      
      scores = {'q': 'q_value',
                'pep': 'pep',
                'p': 'p_value',
                'svm': 'svm_score'}
      highest = {}
      for el in peptides:
          featscore = float(el.xpath('xmlns:%s' % scores[score],
                                     namespaces=ns)[0].text)
          seq = reader.get_peptide_seq(el, ns)
  
          if seq not in highest:
              highest[seq] = {
                  'pep_el': formatting.stringify_strip_namespace_declaration(
                      el, ns), 'score': featscore}
          if score == 'svm':  # greater than score is accepted
              if featscore > highest[seq]['score']:
                  highest[seq] = {
                      'pep_el':
                      formatting.stringify_strip_namespace_declaration(el, ns),
                      'score': featscore}
          else:  # lower than score is accepted
              if featscore < highest[seq]['score']:
                  highest[seq] = {
                      'pep_el':
                      formatting.stringify_strip_namespace_declaration(el, ns),
                      'score': featscore}
          formatting.clear_el(el)
  
      for pep in list(highest.values()):
          yield pep['pep_el']
docs: Filters unique peptides from multiple Percolator output XML files.
          Takes a dir with a set of XMLs, a score to filter on and a namespace.
          Outputs an ElementTree.