for ( ExprNode child : children )
{
if ( child instanceof LeafNode )
{
LeafNode leaf = ( LeafNode ) child;
try
{
if ( schemaManager.getAttributeTypeRegistry().hasDescendants( leaf.getAttribute() ) )
{
// create a new OR node to hold all descendent forms
// add to this node the generalized leaf node and
// replace the old leaf with the new OR branch node
BranchNode orNode = new OrNode();
orNode.getChildren().add( leaf );
children.set( childNumber++, orNode );
// iterate through descendants adding them to the orNode
Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( leaf.getAttribute() );
while ( descendants.hasNext() )
{
LeafNode newLeaf = null;
AttributeType descendant = descendants.next();
if ( leaf instanceof PresenceNode )
{
newLeaf = new PresenceNode( descendant.getOid() );