def branchwise(tree):
    """Return sets of nodes and edges from a dict-based tree.
    
    Parameters
    ----------
    tree: dict
        Representation of a scenario tree with as a dictionary with
        scenario tuple keys and probability values.

    Returns
    -------
    nodes: set
        Set of `nodes` of the tree represented by scenario tuples.
    edges: set
        Set of `edges` of type ``(nodes[i], nodes[j])`` of the tree.
    """
    edges = {(v[0:i], v[0:i+1]) for v in tree for i in range(1, len(v))}
    nodes = {v for e in edges for v in e}
    return nodes, edges