Check equality of DataIterator type properly

- As type attribute of DataIterator is of type Object, we can't just
  compare it with type of edge using ==
- Using equals when it is not null and otherwise comparing with ==
- Similar to https://github.com/jruby/jruby/commit/389bcda7f46ac6770cf961f94329d9e4ec422d81