Method which converts the object instance, its attributes and children to a string of lilypond code

        :return: str of lilypond code

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 = "\\version \"2.18.2\" \n"

        partstrings = []
        ids_loaded = []
        groupings = []
        if len(self.groups) > 0:
            # here we need to do some set union theory
            lstring, groupings, ids_loaded = self.handleGroups()
            lilystring += lstring
        children = [
            child for child in self.GetSortedChildren() if child not in ids_loaded]
        for child in children:
            part = self.getPart(child)
            partstring = part.toLily()
            lilystring += partstring[0]
            partstrings.append(partstring[1])
        lilystring += self.item.toLily()
        lilystring += "<<"
        lilystring += "".join([gstring for gstring in groupings])
        lilystring += "".join([partstring for partstring in partstrings])
        lilystring += ">>"
        return lilystring