code: def _stack_from_spec(self, spec, stack=(), seen_names=()):
          
          if spec.inventory_name() in seen_names:
              raise ansible.errors.AnsibleConnectionFailure(
                  self.via_cycle_msg % (
                      spec.mitogen_via(),
                      spec.inventory_name(),
                      ' -> '.join(reversed(
                          seen_names + (spec.inventory_name(),)
                      )),
                  )
              )
  
          if spec.mitogen_via():
              stack = self._stack_from_spec(
                  self._spec_from_via(spec.inventory_name(), spec.mitogen_via()),
                  stack=stack,
                  seen_names=seen_names + (spec.inventory_name(),),
              )
  
          stack += (CONNECTION_METHOD[spec.transport()](spec),)
          if spec.become() and ((spec.become_user() != spec.remote_user()) or
                                C.BECOME_ALLOW_SAME_USER):
              stack += (CONNECTION_METHOD[spec.become_method()](spec),)
  
          return stack
docs: Return a tuple of ContextService parameter dictionaries corresponding
          to the connection described by `spec`, and any connection referenced by
          its `mitogen_via` or `become` fields. Each element is a dict of the
          form::
  
              {
                  # Optional. If present and `True`, this hop is elegible for
                  # interpreter recycling.
                  "enable_lru": True,
                  # mitogen.master.Router method name.
                  "method": "ssh",
                  # mitogen.master.Router method kwargs.
                  "kwargs": {
                      "hostname": "..."
                  }
              }
  
          :param ansible_mitogen.transport_config.Spec spec:
              Connection specification.
          :param tuple stack:
              Stack elements from parent call (used for recursion).
          :param tuple seen_names:
              Inventory hostnames from parent call (cycle detection).
          :returns:
              Tuple `(stack, seen_names)`.