How to check in custom plugin that nested extension has been used in project?

I have extension and 2 extension nested like:

external {
internal1 {
  }
 internal2 {}
}

how to check that user in build.gradle entered only one of them?

like:

external {
  internal2 {}
  }

?

You can’t. You can only check how the extension objects were configured. What’s your use case?