Implemented recursive version of depth-search.