def toLily(self):
        '''
        Method which converts the object instance, its attributes and children to a string of lilypond code

        :return: str of lilypond code
        '''

        lilystring = ""

        if not self.autoBeam:
            lilystring += "\\autoBeamOff"
        children = self.SortedChildren()
        if not hasattr(self, "transpose"):
            self.transpose = None
        for child in range(len(children)):
            measureNode = self.GetChild(children[child])
            measureNode.autoBeam = self.autoBeam
            lilystring += " % measure " + str(children[child]) + "\n"
            lilystring += measureNode.toLily() + "\n\n"
        return lilystring