You can use the builtin macro let-alist to access value from nested alist, e.g.,
'((foo . ((bar . ((chocolate . "edible") (gold . "inedible")))
(jar . "glass"))))
;; => "edible"
And your x is not an alist, alist is a list of key-value pairs, i.e., ((key1 . val1) (...
I have the following nested alist:
The example does not show a real alist, because its first element, foo, is not a cons cell. I'd personally call it a tree. Functions like assoc-string may handle this, others may ignore such elements, but in general alist functions expect every element to be a cons with a car and a cdr. See (info "(elisp) Lists"...
tramp-methods is an association list.
Which means that you don't have to replace an existing value at all.
When a value is looked up in an alist, only the first match for the key is returned.
Therefore merely pushing a new (KEY . VALUE) onto the front of the list has the desired effect, regardless of whether or not there are other uses of that same KEY in ...