How to model looping constructs in yang?

How to model looping constructs in yang?

Say a self referential structure like linked list:

data llist
{
   int x;
   data *llist;
}

(with some terminal condition to stop looping)

Or some nested if statement

if (...)
{
 if(...)
 {
  if(...)
  {
  }
 }
}

Is it possible to do so?

Or in simple words, is it possible to model yang to have self referential constructs? Say container within same container or list within same list?

Is there any other way to model this?

Thanks,
Harsha

For if there is if-feature statement. I think it will not cover complex scenarios.

For nested constructs - if you know the depth (and the depth is limited) , then you can repeat list definition N times (perhaps with help of grouping - put non key elements into grouping so you do not need to repeat them) . In many cases it is acceptable.

If possible, one option is to generate YANG during build time by some script (e.g. using yangbuilder).

I’d like to know, @shk18: what will model with those structures?