Bug fix: ignore text nodes while checking for matches