First, observe that to simulate depth first search we simply modify the definition of agenda_putl/3 (this puts a list of expanded items onto the agenda) from
agenda_putl(A,L,Anew) :- append(A,L,Anew).
to
agenda_putl(A,L,Anew) :- append(L,A,Anew).
The algorithm loops