def replace(oldEl, newEl):
        # type: (Union[Rule, _RuleConnectable], Union[Rule, _RuleConnectable]) -> Union[Rule, _RuleConnectable]
        """
        Replace element in the parsed tree. Can be nonterminal, terminal or rule.
        :param oldEl: Element already in the tree.
        :param newEl: Element to replace with.
        :return: New element attached to the tree.
        """
        if isinstance(oldEl, Rule):
            return Manipulations.replaceRule(oldEl, newEl)
        if isinstance(oldEl, (Nonterminal, Terminal)):
            return Manipulations.replaceNode(oldEl, newEl)
Replace element in the parsed tree. Can be nonterminal, terminal or rule.
        :param oldEl: Element already in the tree.
        :param newEl: Element to replace with.
        :return: New element attached to the tree.