Търсене в дълбочина (Depth-first)
depth_first([[Goal|Path]|_],Goal,FinalPath):-
reverse([Goal|Path],FinalPath).
depth_first([Path|Stack],Goal,FinalPath) :-
append(NewPaths,Stack,NewStack),
depth_first(NewStack,Goal,FinalPath).
extend([Node|Path],NewPaths) :-
findall([NewNode,Node|Path],
not member(NewNode,[Node|Path])),