code: def getmetadata(self, key=None):
          
          if self.metadata:
              d =  self.doc.submetadata[self.metadata]
          elif self.parent:
              d =  self.parent.getmetadata()
          elif self.doc:
              d =  self.doc.metadata
          else:
              return None
          if key:
              return d[key]
          else:
              return d
docs: Get the metadata that applies to this element, automatically inherited from parent elements