modified searchForTheNodeWithCharacter function