Generating breadth-first expression for gray scale quadtree