<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def spread(nodes, n):
 """Distrubute master instances in different nodes { "192.168.0.1": [node1, node2], "192.168.0.2": [node3, node4], "192.168.0.3": [node5, node6] } => [node1, node3, node5] """

    target = []

    while len(target) < n and nodes:
        for ip, node_group in list(nodes.items()):
            if not node_group:
                nodes.pop(ip)
                continue
            target.append(node_group.pop(0))
            if len(target) >= n:
                break
    return target