}
else if( head instanceof PropertySegment )
{
final String name = ( (PropertySegment) head ).getPropertyName();
final Property property = this.propertiesByName.get( name.toLowerCase() );
final ModelPath tail = path.tail();
if( property instanceof ElementHandle )
{
final Element element = ( (ElementHandle<?>) property ).content();
if( element != null )
{
return element.visit( tail, visitor );
}
}
else if( property instanceof ElementList )
{
for( Element element : (ElementList<?>) property )
{
if( ! element.visit( tail, visitor ) )
{
return false;
}
}
}
return true;
}
else if( head instanceof TypeFilterSegment )
{
final String t = type().getSimpleName();
boolean match = false;
for( String type : ( (TypeFilterSegment) head ).getTypes() )
{
if( type.equalsIgnoreCase( t ) )
{
match = true;
break;
}
}
if( match )
{
return visit( path.tail(), visitor );
}
return true;
}
else if( head instanceof AllSiblingsSegment )
{
final Property parent = parent();
if( parent instanceof ElementList )
{
final ModelPath p = ( new ModelPath( parent.name() ) ).append( path.tail() );
return parent.element().visit( p, visitor );
}
}
}