A small implementation of breadth-first traversal