Main algorithm for the pathfinding mediator service (#14)