סריקה לרוחב של עץ

public static void
HorizentalScan(BinNode<Integer>
t) {

      Queue<BinNode<Integer>>
q = new
Queue<BinNode<Integer>>();

      BinNode<Integer>
tmp;

      q.insert(t);

      while (!q.isEmpty())
{

            tmp = q.remove();

            System.out.print(tmp.getValue()+",");

            if (tmp.hasLeft())
{

                  q.insert(tmp.getLeft());

            }

            if (tmp.hasRight())
{

                  q.insert(tmp.getRight());

            }

      }

      System.out.println();

}