NEXUS-2450: NPE fix

Initial implementation invoked parts it should not invoke
even with null result, causing NPE.

Problem was badly located logic within the for-loop.