def _write_newick_internal_label(out, node_id, node, otu_group, label_key, needs_quotes_pattern):
    """`label_key` is a string (a key in the otu object) or a callable that takes two arguments:
        the node, and the otu (which may be None for an internal node)
    If `leaf_labels` is not None, it shoulr be a (list, dict) pair which will be filled. The list will
        hold the order encountered,
        and the dict will map name to index in the list
    """
    otu_id = node.get('@otu')
    if is_str_type(label_key):
        if otu_id is None:
            return
        otu = otu_group[otu_id]
        label = otu.get(label_key)
    else:
        label = label_key(node_id, node, None)
    if label is not None:
        label = quote_newick_name(label, needs_quotes_pattern)
        out.write(label)
`label_key` is a string (a key in the otu object) or a callable that takes two arguments:
        the node, and the otu (which may be None for an internal node)
    If `leaf_labels` is not None, it shoulr be a (list, dict) pair which will be filled. The list will
        hold the order encountered,
        and the dict will map name to index in the list