public SolutionItem solve(SolutionItem puzzleToSolve)
    {
        //determine what is the first number to insert the puzzle:
        puzzleToSolve.nextToInsert = getNextNumToInsert(puzzleToSolve.puzzle, 1);
        puzzlesList.addLast(puzzleToSolve);

        while( true )
        {
            ++numSteps;
            if(puzzlesList.isEmpty())
            {
                break;
            }
            SolutionItem current = puzzlesList.getLast();
            int X = current.X_ofNextItem;
            int Y = current.Y_ofNextItem;
            int numToInsert = current.nextToInsert;

//            SolutionItem new_si = insertNumberToPuzzle(current.puzzle.clone(), numToInsert, X, Y+1);
            SolutionItem new_si = smartInsertNumberToPuzzle(current.puzzle.clone(), numToInsert, X, Y+1);

            if(new_si == null)	//if insertion failed - this path invalid
            {
                //path is invalid, roll back:
                //NOTE: not only I do not put it on the list, i throw the last item which caused this stuck:
                puzzlesList.removeLast();
                continue;
            }

            //update the current where its next number was located (see SolutionItem doc)
            current.X_ofNextItem = new_si.X_ofNextItem;
            current.Y_ofNextItem = new_si.Y_ofNextItem;



            if(new_si.puzzle.isSolved())
            {
                System.out.println("solved the puzzle in " + numSteps + " steps.");
                return new_si;
            }

            if(new_si.puzzle.isNumberFinished(numToInsert))    //next iteration we insert the sequential number 
            {
                new_si.nextToInsert = getNextNumToInsert(new_si.puzzle, numToInsert + 1);
                //if we insert "new" number than start search from beginning: (0,0)
                new_si.X_ofNextItem = 0;
                //i put -1 bcoz after popping, i inc the Y index. this is the same reason i create in the servlet 
                //the SolutionItem with -1:
                new_si.Y_ofNextItem = -1;   

            }
            else
            {
                new_si.nextToInsert = numToInsert;
            }

            puzzlesList.addLast(new_si);

        }
        
        System.out.println("WOW! no solutions. num steps: " + numSteps);
        return null;
    }