docs: def _LookUpStack(self, name):
          """Look up the stack for the given name."""
          i = len(self.stack) - 1
          while 1:
              frame = self.stack[i]
              if name == '@index':
                  if frame.index != -1:  # -1 is undefined
                      return frame.index  # @index is 1-based
              else:
                  context = frame.context
                  if hasattr(context, 'get'):  # Can't look up names in a list or atom
                      try:
                          return context[name]
                      except KeyError:
                          pass
              
              i -= 1  # Next frame
              if i <= -1:  # Couldn't find it anywhere
                  return self._Undefined(name)