<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_nested_php_args(data, prefix_key=None):
 """ This function will take either a dict or list and will recursively loop through the values converting it into a format similar to a PHP array which Ubersmith requires for the info portion of the API's order.create method. """

    is_root = prefix_key is None
    prefix_key = prefix_key if prefix_key else ''

    if islist(data):
        data_iter = data if is_root else enumerate(data)
        new_data = [] if is_root else {}
    elif isdict(data):
        data_iter = list(data.items())
        new_data = {}
    else:
        raise TypeError('expected dict or list, got {0}'.format(type(data)))

    if islist(new_data):
        def data_set(k, v):
            new_data.append((k, v))
        def data_update(d):
            for k, v in list(d.items()):
                new_data.append((k, v))
    else:
        def data_set(k, v):
            new_data[k] = v
        data_update = new_data.update

    for key, value in data_iter:
        end_key = prefix_key + (str(key) if is_root else '[{0}]'.format(key))
        if _is_leaf(value):
            data_set(end_key, value)
        else:
            nested_args = to_nested_php_args(value, end_key)
            data_update(nested_args)

    return new_data