Breath First search implementation