 			if not child
 				return null
 
-			if not nodeFilter or nodeFilter(child)
+			if not nodeFilter or @is(child, nodeFilter)
 				return child
 
 			child = child.nextElementSibling

			if not child
				return null

			if not nodeFilter or nodeFilter(child)
				return child

			child = child.previousElementSibling

			if not sibling
				return null

			if not nodeFilter or @is(sibling, nodeFilter)
				return sibling


