Write a polyfill for flattening out an array.
Implement flatten_array(arr), which accepts a list containing values or nested lists and returns a new one-dimensional list with all nesting removed. Preserve left-to-right order, retain duplicate values, and do not mutate arr. For example, [1, [2, [3]], 4] becomes [1, 2, 3, 4], while [] becomes [].
def flatten_array(arr):