get_depth_str

        High-level api: Produce a string that represents tree hierarchy.

        Parameters
        ----------

        element : `Element`
            A node in model tree.

        type : `str`
            Type of model content required. Its value can be 'other', 'rpc', or
            'notification'.

        Returns
        -------

        str
            A string that represents tree hierarchy.

def get_depth_str(element, type='other'):
        '''get_depth_str

        High-level api: Produce a string that represents tree hierarchy.

        Parameters
        ----------

        element : `Element`
            A node in model tree.

        type : `str`
            Type of model content required. Its value can be 'other', 'rpc', or
            'notification'.

        Returns
        -------

        str
            A string that represents tree hierarchy.
        '''

        def following_siblings(element, type):
            if type == 'rpc' or type == 'notification':
                return [s for s in list(element.itersiblings()) \
                        if s.get('type') == type]
            else:
                return [s for s in list(element.itersiblings()) \
                        if s.get('type') != 'rpc' and \
                           s.get('type') != 'notification']

        ancestors = list(reversed(list(element.iterancestors())))
        ret = ' '
        for i, ancestor in enumerate(ancestors):
            if i == 1:
                if following_siblings(ancestor, type):
                    ret += '|  '
                else:
                    ret += '   '
            else:
                if ancestor.getnext() is None:
                    ret += '   '
                else:
                    ret += '|  '
        ret += '+--'
        return ret