class DrlxParseUtil {

    public static Expression prepend(Expression scope, Expression expr) {
        final Optional<Expression> rootNode = findRootNodeViaScope(expr);
        if (rootNode.isPresent()) {
            if(rootNode.get() instanceof ThisExpr) {
                rootNode.get().replace(scope);
            } else if (rootNode.get() instanceof NodeWithOptionalScope<?>) {
                ((NodeWithOptionalScope) rootNode.get()).setScope(scope);
            }
            return expr;
        } else {
            throw new IllegalStateException("No root node was found!");
        }
    }

    private  DrlxParseUtil();

}