Depth-first search
In computer science, depth-first search (DFS) is a method used for traversing a graph. It starts at an arbitrary item of a graph and explores as far as possible along each branch before backtracking.