Another algorithm for the index selection

If forms are not on the same level of nesting, then they have the same codes