this is wrong b/c it is depth-first