Explores as far as possible along each branch using a stack, not guaranteeing the shortest path in unweighted graphs.
stack ← [start]parent[start] ← nullwhile stack not empty:v ← pop(stack)for each neighbor u of v:if u not seen:parent[u] ← vpush(stack, u)if goal reached: reconstruct path