Is there a better way for avoiding error of circular dependency for module xxx

I’ve got two modules A and B, both of them have a leafref type of each other, so that

  1. module A should import B
  2. module B should import A

if we really do the simple import we’ll get error: circular dependency for module xxx.

The way we have to do is split module A and B into two parts

  1. A -> A1, A2
  2. B-> B1, B2
  3. A1 import A2, A1 import B2
  4. B1 import B2, B1 import A2

again, if module A, B, C ref each other of any two module, we have to split each of them.

  1. A-> A1, A2
  2. B-> B1, B2
  3. C-> C1, C2
  4. A1 import A2, A1 import B2 A1 import C2
  5. B1 import B2, B1 import A2, B1 import C2
  6. C1 import C2, C1 import A2, C1 import B2

Well, how terrible it turn to be, when we have a lot of modules?

Unfortunately, if we happen to the requirement B2 have import C2, and C1 have to import A1, we need split the modules again carefully and patiently.

Even we could split the modules correctly but look at what the result it leads to, there are too many module slices to maintain,

So is there a better way to solve the problem without extracting the common yang data model into slices?

I’m not aware of any better alternatives to get around this.