Implement new assert_nD utility function