docs: def lru_append(kc, lru, kckey, maxsize):
      """Delete old data from ``kc``, then add the new ``kckey``.
  
      :param kc: a three-layer keycache
      :param lru: an :class:`OrderedDict` with a key for each triple that should fill out ``kc``'s three layers
      :param kckey: a triple that indexes into ``kc``, which will be added to ``lru`` if needed
      :param maxsize: maximum number of entries in ``lru`` and, therefore, ``kc``
  
      """
      if kckey in lru:
          return
      while len(lru) >= maxsize:
          (peb, turn, tick), _ = lru.popitem(False)
          if peb not in kc:
              continue
          kcpeb = kc[peb]
          if turn not in kcpeb:
              continue
          kcpebturn = kcpeb[turn]
          if tick not in kcpebturn:
              continue
          del kcpebturn[tick]
          if not kcpebturn:
              del kcpeb[turn]
          if not kcpeb:
              del kc[peb]
      lru[kckey] = True