Updated mapPotential to support N-dimensional topology (and other improvements)

Fixes https://github.com/numenta/nupic/issues/837. Builds on https://github.com/numenta/nupic/pull/879.
Not yet ready for merge, requires C++ side changes as well.

In addition to supporting N-dimensional topology, I've also significantly sped up (and simplified) `getNeighborsND`, and fixed a potential bug in initializing `columnDimensions` and `inputDimensions`.

@subutai @iandanforth or @scottpurdy please review before I make the parallel changes in C++.