DRY -- this is duplicated in both `GlobalIndex` and `LocalArray`.  This should be refactored into a top-level function since it doesn't use `self` at all.