Added DFS algorithm.

It needs minor change as it's searching only one root now. When path
ends it needs to switch to other path.