This array flattening functionality seems useful outside the context of data selections. Can we add it to the `array` namespace and invoke that here to promote code reuse?