added breadth-first-traversing