StackOverFlowExcp : The requested operation caused a stack overflow

Hello everyone,
I’m making a card game and when i shuffle the deck, the error occurs:

StackOverflowException: The requested operation caused a stack overflow.

It’s been a day but i still haven’t realised the source problem.
This is my full code:

public class Deck_Game2 : MonoBehaviour
{
    public List<Card> cards, playerCards, enemyCards;
    public GameObject posP,posE;
    public bool click;
    
    void Awake()
    {
        posP = GameObject.Find("PlayerCardPos");
        posE = GameObject.Find("EnemyCardPos");
        click = false;
    }
    
    public void Origi()
    {
        if (click == false)
        {
            Begin();
            click = true;
        }
        cards[0].transform.position = new Vector3(0, 0);
        for (int i = 1; i < cards.Count; i++)
        {
            Card temp = cards[i - 1];
            cards[i].transform.position = new Vector3(temp.transform.position.x - 0.075f, temp.transform.position.y, temp.transform.position.z + 0.1f);
        }
    }

    private void Begin()
    {
        for (int i = 0; i < cards.Count && playerCards.Count < 10; i++)
        {
            playerCards.Add(cards[i]);
            cards.Remove(cards[i++]);
            enemyCards.Add(cards[i]);
            cards.Remove(cards[i]);
        }
        SetUp(playerCards, posP, false);
        SetUp(enemyCards, posE, true);

        Origi();
    }

    private void SetUp(List<Card> hold, GameObject p, bool confrim)
    {
        hold[0].transform.position = p.transform.position;
        hold[0].isBack = confrim;
        for (int i = 1; i < hold.Count; i++)
        {
            Card temp = hold[i - 1];
            hold[i].transform.position = new Vector3(temp.transform.position.x - 0.4f, temp.transform.position.y, temp.transform.position.z + 0.4f);
            hold[i].isBack = confrim;
        }
    }

}
public void Shuffle()
{
    textWarning.SetActive(false);
    for (int j = 1; j < deckgame2.cards.Count; j++)
    {
        int random = Random.Range(0, deckgame2.cards.Count);
        Card temp = deckgame2.cards[j];
        deckgame2.cards[j] = deckgame2.cards[random];
        deckgame2.cards[random] = temp;
    }
    deckgame2.Origi();
}

I hopp there’ll be someone to help me with this.
Thank you guys!!!

It looks like excessive mutual recursion: Begin calls Origi, and Origi calls Begin.

    flowchart
         elsewhere --> Begin
         elsewhere --> Origi
         Begin --> Origi
         Origi --> Begin

To build on @kdchabuk 's comment, it is that recursive flow, plus click is set to true AFTER calling Begin from Origi, meaning the flow returns to Origi with click still being false. As a result, it bounces back and forth between Begin and Origi until there are too many function calls on the call stack and you get your exception.

If you move that one line (click = true) above the call to Begin, it might behave more like what you’d expect it to.