Fixed crashing bug with getNeighborsND (wrapAround=true case)

Fixes https://github.com/numenta/nupic.core/issues/125

@scottpurdy 
I think it would be easier to read to use proper if/else blocks instead of inlining them. I guess this is a personal preference though so up to you.