def homogenize_unit_array(arr, unit=None):
    """ takes an list with quantities and turns it into a numpy array with a
    single associated unit
    
    `arr` is the (not nested) list of values
    `unit` defines the unit to which all items are converted. If it is omitted,
        the unit is determined automatically from the first array element
    """
    if unit is None:
        try:
            # extract unit from array
            unit = arr[0] / arr[0].magnitude
        except (AttributeError, IndexError):
            # either `arr` was not an array or it didn't carry units 
            return arr
        
    # convert all values to this unit and return their magnitude
    arr = [val.to(unit).magnitude for val in arr]
    
    # return the array with units
    return arr * unit