implementation of depth first search - incomplete