from typing import List


def recursive_state_network(network, node: str, root_path: List[str], depth: int, blacklist: List[str]):
    """
    Searches the network for all permutations of all paths leaving the starting node, without revisiting any node
    :param network: a graph of nodes, given as a dictionary where keys are node labels and values are a list of edges by
        neighboring node name
    :param node: the node to start the search
    :param root_path: prefix added to the resulting paths
    :param depth: number of nodes to traverse from the start node
    :param blacklist: any nodes to ignore, used recursively to prevent revisiting nodes
    :return: List of lists of node labels
    """
    local_path = root_path.copy()
    local_blacklist = blacklist.copy()
    if depth == 1:
        local_path.append(node)
        return local_path

    list_of_paths = []
    local_path.append(node)
    local_blacklist.append(node)
    for next_step in network[node]:
        if next_step not in blacklist:
            subresult = recursive_state_network(network, next_step, local_path, depth-1, local_blacklist)
            if depth == 2:
                list_of_paths.append(subresult)
            else:
                list_of_paths.extend(subresult)
    return list_of_paths