Exchanged instanceof with simple null check
Fixed complexity problem
Merge pull request #1828 from noctarius/instanceof-exchange

Exchanged instanceof with simple null check