def format(self, max_depth=None, start=None, stop=None, ends=True):
        max_depth = self._get_valid_maxdepth(max_depth)
        condition = lambda node, _: node.isleaf

        leaves = self.find_all(0, max_depth=max_depth, condition=condition)
        if start:
            for i, leaf in enumerate(leaves):
                if leaf is start:
                    if not ends:
                        i += 1
                    leaves = leaves[i:]
                    break
        if stop:
            for i, leaf in enumerate(leaves):
                if leaf is stop:
                    if ends:
                        i += 1
                    leaves = leaves[:i]
                    break

        # insert a space when 2 NAMEs are next to each other
        for i in range(len(leaves) - 1, 0, -1):
            if leaves[i].toknum == leaves[1 - i].toknum == token.NAME:
                leaves.insert(i, " ")
        return "".join(str(n) for n in leaves)
dataset/ETHPy150Open KristoforMaynard/SublimeAutoDocstring/dparse.py/STNode.format/swapped operands of `-`