Some changes in logics in getNodesToDelete