ADD: Implementation of the depth first search algorithm.