def get_new_node_id():
    """Return a new unused id for the nodes."""
    ### retrieve existing node ids
    existing_ids = APP_REFS.data[NODES_KEY].keys()

    ### get a callable to generate integers from 0 to
    ### infinite
    get_new_id = count().__iter__().__next__

    ### keep generating a new id while until it cannot
    ### be found among the existing ones

    while True:

        new_id = get_new_id()
        if new_id not in existing_ids:
            break

    ### finally return the new unused id
    return new_id
Return a new unused id for the nodes.
nodezator/editing/objinsert.py