Breadth first search in java with queues