def makeChildren(patchMessageReferenceNode):
    ref_keys = patchMessageReferenceNode.keys()
    ref_keys.sort()
    for messageId in ref_keys:
        referenceNode = patchMessageReferenceNode[messageId]
        utils.verboseOutput(verbose, "Managing Message Id:", referenceNode.get_node())
        referenceIds = referenceNode.get_references()
        referenceIdsClone = referenceIds[:]
        utils.verboseOutput(verbose, "Cloned References: ", referenceIdsClone)
        if len(referenceIds) > 0:
            nextNode = patchMessageReferenceNode[referenceIdsClone[0]]
            referenceIdsClone.remove(referenceIdsClone[0])
            while nextNode != None:
                utils.verboseOutput(verbose, "Next Node: ", nextNode.get_node())
                utils.verboseOutput(verbose, "Curent Node: ", referenceNode.get_node())
                utils.verboseOutput(verbose, "REF: ", referenceIdsClone)
                nextNode = handleNode(referenceNode, nextNode, referenceIdsClone, patchMessageReferenceNode)
                utils.verboseOutput(verbose, "Next Node: ", nextNode.get_node())
                utils.verboseOutput(verbose, "Curent Node: ", referenceNode.get_node())
                utils.verboseOutput(verbose, "REF: ", referenceIdsClone)
                nextNode = handleNode(referenceNode, nextNode, referenceIdsClone, patchMessageReferenceNode)


if __name__ == "__main__":
    arguments = sys.argv
    verbose = "false"
    pseudoArgs = arguments[:]
    while len(pseudoArgs) > 1:
        argument = pseudoArgs[1]
        if argument == "-v" or argument == "--verbose":
            verbose = "true"
        pseudoArgs.remove(argument)
    utils.verboseOutput(verbose, "Checking POP3 for gmail")
    try:
        emailConfig = xmlConfigs.initializePopConfig("./email-configuration.xml")
        myPop = emailConfig.get_pop3_connection()
        numMessages = len(myPop.list()[1])
        patchMessages = dict()
        for i in range(numMessages):
            utils.verboseOutput(verbose, "Index: ", i)
            totalContent = ""
            for content in myPop.retr(i + 1)[1]:
                totalContent += content + "\n"
            msg = email.message_from_string(totalContent)
            if "subject" in msg:
                subject = msg["subject"]
                subjectPattern = "^\[.*PATCH.*\].+"
                subjectMatch = re.match(subjectPattern, subject)