Find shortest path between two specified terms