basic depth first search