Breath First Search Algorithm in prolog