docs: def element(self, tag_path, test=None, **attributes):
          """given a tag in xpath form and optional attributes, find the element in self.root or return a new one."""
          xpath = tag_path
          tests = ["@%s='%s'" % (k, attributes[k]) for k in attributes]
          if test is not None:
              tests.insert(0, test)
          if len(tests) > 0:
              xpath += "[%s]" % ' and '.join(tests)
          e = self.find(self.root, xpath)
          if e is None:
              tag = tag_path.split('/')[-1].split('[')[0]
              tagname = tag.split(':')[-1]
              if ':' in tag:
                  nstag = tag.split(':')[0]
                  tag = "{%s}%s" % (self.NS[nstag], tagname)
              e = etree.Element(tag, **attributes)
          return e