private bool TryPeekDestination(out IObjective destination) { if (this.destinations.Count == 0) { destination = null; return(false); } destination = this.destinations.Peek(); // Dequeue objectives until we have a valid one. while (!destination.Validate()) { this.destinations.Dequeue(); if (this.destinations.Count > 0) { destination = this.destinations.Peek(); } else { destination = null; return(false); } } return(true); }