Bunch of errors after deleting the 4 dialogues

I added
if(nodes.Count==0) CreateNode(null);
at the beggining of OnValidate() but it did not work, showing same errors after deleting the dialogues and creating a new one. The thing is I also already had that line of code also in the Awake().

Things I tried:

-deleting whole Awake method (because I thougth it wouldnt work if that line of code was repeated twice) and copying it into the onvalidate method

-copying that line of code in both awake and onvalidate() at the start of the methods

-copying that line of code into onvalidate() at the start of the method

whatever I try it keeps showing the same errors I said. Am I inserting the line of code in the wrong spot? Do i have to delete the whole awake() and insert it in onvalidate() or what is the exact process?

private void OnValidate()

{

    if(nodes.Count==0) {CreateNode(null)};

   

nodeLookup.Clear();

foreach (DialogueNode node in GetAllNodes())

{

    nodeLookup[node.uniqueID] = node;

}