class ExecutableExpansionVisitor extends BaseVisitor {

    @Override
    public Object visit(ASTJexlScript node, Object data) {
        // no reason to go any further if the query is executable because that means there couldn't be a problem
        boolean executable = ExecutableDeterminationVisitor.isExecutable(node, config, helper);
        if (!executable) {
            // flatten the tree first
            JexlNode copy = TreeFlatteningRebuildingVisitor.flatten(node);
            // see if we can find a place where expanding the query will make it executable
            super.visit(copy, new ExpansionTracker(null));
            
            // if the query is now executable, return it otherwise ignore the work done
            if (ExecutableDeterminationVisitor.isExecutable(copy, config, helper)) {
                return copy;
            }
        }
        
        return node;
    }

    public  ExecutableExpansionVisitor(ShardQueryConfiguration config, MetadataHelper helper);

}