docs: def context(self, key, method):
          """A helper method to attach a value within context.
  
          :param key: the key attached to the context.
          :param method: the constructor function.
          :return: the value attached to the context.
          """
          ctx = stack.top
          if ctx is not None:
              if not hasattr(ctx, key):
                  setattr(ctx, key, method())
              return getattr(ctx, key)