Offset lookup is extremely expensive under some conditions with the current iterators. Ideally, you'd perform your node type checks (line 437, 440 & 443) first to avoid calculating the offset unnecessarily.