Modifying Graph Search to Dynamically Create Search Trees

Recall the generic Search algorithm:

Search(G,s,adder)
   for each u ∈ V[G]-{s} do
      open[u] = true
      d[u] = ∞
      pred[u] = null
   open[s] = false
   d[s] = 0
   pred[s] = null
   DEQ = {s}
   while DEQ ≠ {} do
      u = Remove[DEQ]
      for each v ∈ Adj[u] do
         if open[v] = true
            then open[v] = false
                 d[v] = d[u] + 1
                 pred[v] = u
                 Add(DEQ,v,adder)