def match_label(tree1, tree2):
    """Generate a list of pairs of nodes in two trees with matching labels.

    Parameters
    ----------
    tree1 : skbio.TreeNode
        tree 1 for comparison
    tree2 : skbio.TreeNode
        tree 2 for comparison

    Returns
    -------
    list of tuple of (skbio.TreeNode, skbio.TreeNode)

    Examples
    --------
    >>> from skbio import TreeNode
    >>> tree1 = TreeNode.read(['((a,b)x,(c,d)y);'])
    >>> tree2 = TreeNode.read(['(((a,b)x,c)y,d);'])
    >>> matches = match_label(tree1, tree2)
    >>> len(matches)
    6
    >>> print([' - '.join([','.join(sorted(node.subset())) for node in pair])
    ...        for pair in matches if not any(node.is_tip() for node in pair)])
    ['a,b - a,b', 'c,d - a,b,c']
    """
    l2ns = []
    for tree in (tree1, tree2):
        l2ns.append({})
        for node in tree.traverse(include_self=True):
            label = node.name
            if label not in (None, ''):
                if label in l2ns[-1]:
                    raise ValueError('Duplicated node label "%s" found.'
                                     % label)
                l2ns[-1][label] = node
    res = []
    for label in sorted(l2ns[0]):
        if label in l2ns[1]:
            res.append((l2ns[0][label], l2ns[1][label]))
    return res