Depth-First Search

Take a look at the wikipedia: http://en.wikipedia.org/wiki/Depth-first_search