def softDuplicateState(automaton, state):
    """Create new state in the automaton and if the duplicated state is
    initial or accepting, the new state will be too.

    Args:
        automaton (Nfa): Automaton in which the new state will be added.
        state (string): Duplicated state.

    Returns:
        string: The name of new state.
    """

    newState = automaton.createNewState("tmp")
    if state in automaton.initialStates:
        automaton.initialStates.add(newState)
    if state in automaton.acceptingStates:
        automaton.acceptingStates.add(newState)
    
    return newState