added depth first next node algo