def remove_repetition_of_nonterminals_from_productions(grammar_in_text: str):
    """ Remove nonterminal repeats on the left side of the rule
    For example:
    grammar: S -> a S b
             S -> a b
    grammar after function execution: S -> a S b | a b
    """
    productions = dict()
    for production in grammar_in_text.splitlines():
        if "->" not in production:
            continue

        head, body = production.split(" -> ")
        if head in productions:
            productions[head] += " | " + body
        else:
            productions[head] = body

    grammar_new = str()
    for nonterminal in productions:
        grammar_new += f'{nonterminal} -> {productions[nonterminal]}\n'
    return grammar_new[:-1]