Modifying Graph Search to Dynamically Create Search Trees (Again)

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