Implementation of Beam path finding algorithm.