@staticmethod
def replaceRule(oldRule, newRule):
    """
        Replace instance of Rule with another one.
        :param oldRule: Instance in the tree.
        :param newRule: Instance to replace with.
        :return: New instance attached to the tree.
        """
    for par in oldRule.from_symbols:
        par._set_to_rule(newRule)
        newRule._from_symbols.append(par)
    for ch in oldRule.to_symbols:
        ch._set_from_rule(newRule)
        newRule._to_symbols.append(ch)
    return newRule
