code: def filter_tree(tree):
      
      to_remove = []
      for elem in tree.findall('urldata'):
          valid = elem.find('valid')
          if valid is not None and valid.text == '0' and \
             valid.attrib.get('result', '').startswith('401'):
              to_remove.append(elem)
      root = tree.getroot()
      for elem in to_remove:
          root.remove(elem)
docs: Filter all 401 errors.