def get_splits(tree_root, intern = True):
    """
    Walk through all the tree nodes and returns the splits in a python dict.

    Parameters
    ----------
    tree_root : VascularTree
        The starting node to search for splits.
    intern    : bool
        If False, also return the splits for the leaves.

    Returns
    -------
    splits    : dict.

    """
    
    splits_dic = {}
    
    for node in tree_root.descendants():
        
        if not intern:
            splits_dic[node.node_id] = set(node.get_leaves_labels())
            
        elif node.parent is not None and node.children != []:
            splits_dic[node.node_id]=node.get_leaves_labels()
    
    return splits_dic