Factored code, added breadth first.