code: def find_kwupdate_location(self,hdr,keyword):
          
          # start by looping through the full templates
          kw_list = None
          last_kw = None
          for extn in self.fullhdrs:
              if keyword in extn:
                  #indx = extn.ascard.index_of(keyword)
                  indx = extn.index(keyword)
                  kw_list = list(extn.keys())[:indx]
                  break
          if kw_list:
              # find which keyword from this list exists in header to be updated
              for kw in kw_list[::-1]:
                  if kw in hdr:
                      last_kw = kw
                      break
          # determine new value for the last keyword found before the HISTORY kws
          if last_kw is None:
              hdrkeys = list(hdr.keys())
              i = -1
              last_kw = hdrkeys[i]
              while last_kw == 'HISTORY':
                  i -= 1
                  last_kw = hdrkeys[i]
  
          return last_kw
docs: Find the last keyword in the output header that comes before the new
          keyword in the original, full input headers.
          This will rely on the original ordering of keywords from the original input
          files in order to place the updated keyword in the correct location in case
          the keyword was removed from the output header prior to calling this method.