This can be easily solved by a class of algorithms called "search algorithms". Most famous ones are "Breadth-first search" and "Depth-first search". They have many variations like "Depth limited depth-first search" and "Iterative deepening depth-first search". If you include heuristics, then you have other variations like "A" and "Iterative deepening A". These are pretty well known and relatively easy to implement.