if ( buf == null )
if ( log.isWarnEnabled() )
    public void visit( ExprNode node )    {        if ( node instanceof PresenceNode )        {            PresenceNode pnode = ( PresenceNode ) node;                        try            {                pnode.setAttribute( registry.getOid( pnode.getAttribute() ) );            }            catch ( NamingException e )            {                log.error( "Failed to normalize filter node attribute: " + pnode.getAttribute(), e );                RuntimeException rte = new RuntimeException( e.getMessage() );                rte.initCause( e );                throw rte;            }            return;        }        if ( node instanceof SimpleNode )        {            SimpleNode snode = ( SimpleNode ) node;            String normalized;            try            {                // still need this check here in case the top level is a leaf node                // with an undefined attributeType for its attribute                if ( !ncn.isDefined( snode.getAttribute() ) )                {                    normalized = snode.getValue();                }                else if ( Character.isDigit( snode.getAttribute().charAt( 0 ) ) )                {                    normalized = ncn.normalizeByOid( snode.getAttribute(), snode.getValue() );                }                else                {                    normalized = ncn.normalizeByName( snode.getAttribute(), snode.getValue() );                }            }            catch ( NamingException e )            {                log.error( "Failed to normalize filter value: " + e.getMessage(), e );                RuntimeException rte = new RuntimeException( e.getMessage() );                rte.initCause( e );                throw rte;            }            try            {                snode.setAttribute( registry.getOid( snode.getAttribute() ) );            }            catch ( NamingException e )            {                log.error( "Failed to normalize filter node attribute: " + snode.getAttribute(), e );                UndefinedFilterAttributeException rte = new UndefinedFilterAttributeException( snode, e.getMessage() );                rte.initCause( e );                throw rte;            }                        snode.setValue( normalized );            return;        }        if ( node instanceof BranchNode )        {            BranchNode bnode = ( BranchNode ) node;            StringBuffer buf = null;            for ( int ii = 0; ii < bnode.getChildren().size(); ii++ )            {                // before visiting each node let's check to make sure non-branch children use                // attributes that are defined in the system, if undefined nodes are removed                ExprNode child = ( ExprNode ) bnode.getChildren().get( ii );                if ( child.isLeaf() )                {                    LeafNode ln = ( LeafNode ) child;                    if ( !ncn.isDefined( ln.getAttribute() ) )                    {                        if ( buf == null )                        {                            buf = new StringBuffer();                        }                        else                        {                            buf.setLength( 0 );                        }                        buf.append( "Removing leaf node based on undefined attribute '" );                        buf.append( ln.getAttribute() );                        buf.append( "' from filter." );                        log.warn( buf.toString() );                        // remove the child at ii                        bnode.getChildren().remove( child );                        ii--; // decrement so we can evaluate next child which has shifted to ii                        continue;                    }                }                // -----------------------------------------------------------                // If there is an exception                // -----------------------------------------------------------                try                {                    visit( child );                }                catch( UndefinedFilterAttributeException e )                {                    bnode.getChildren().remove( ii );                    ii--;                    continue;                }            }            // now see if any branch child nodes are damaged (NOT without children,            // AND/OR with one or less children) and repair them by removing branch            // nodes without children and replacing branch nodes like AND/OR with            // their single child if other branch nodes do not remain.            for ( int ii = 0; ii < bnode.getChildren().size(); ii++ )            {                ExprNode unknown = ( ExprNode ) bnode.getChildren().get( ii );                if ( !unknown.isLeaf() )                {                    BranchNode child = ( BranchNode ) unknown;                    // remove child branch node that has no children left                    if ( child.getChildren().size() == 0 )                    {                        // remove the child at ii                        bnode.getChildren().remove( child );                        ii--; // decrement so we can evaluate next child which has shifted to ii                        continue;                    }                    // now for AND & OR nodes with a single child left replace them                    // with their child at the same index they AND/OR node was in                    if ( child.getChildren().size() == 1 && child.getOperator() != BranchNode.NOT )                    {                        bnode.getChildren().remove( child );                        if ( ii >= bnode.getChildren().size() )                        {                            bnode.getChildren().add( child.getChild() );                        }                        else                        {                            bnode.getChildren().add( ii, child.getChild() );                        }                    }                }            }        }    }