@classmethod
def _build_tree(cls, node, show_pk=True, max_depth=None, follow_links=(),
    depth=0):
    """Return string with tree."""
    if max_depth is not None and depth > max_depth:
        return None
    children = []
    for entry in sorted(node.get_outgoing(link_type=follow_links).all(),
        key=cls._ctime):
        child_str = cls._build_tree(entry.node, show_pk, follow_links=
            follow_links, max_depth=max_depth, depth=depth + 1)
        if child_str:
            children.append(child_str)
    out_values = []
    if children:
        out_values.append('(')
        out_values.append(', '.join(children))
        out_values.append(')')
    lab = node.__class__.__name__
    if show_pk:
        lab += ' [{}]'.format(node.pk)
    out_values.append(lab)
    return ''.join(out_values)
