class SmsRouteTree implements RequestHandler {

    @Override
    public Promise<ActionResponse, ResourceException> handleAction(Context context, ActionRequest request) {
        String remainingUri = context.asContext(UriRouterContext.class).getRemainingUri();
        String action = request.getAction();
        boolean forUI = Boolean.parseBoolean(request.getAdditionalParameter(FOR_UI));

        if (NEXT_DESCENDENTS.equals(action) && remainingUri.isEmpty()) {
            JsonValue result = json(object(field("result", array())));
            for (Map.Entry<String, RequestHandler> subRoute : handlers.entrySet()) {
                if (!subRoute.getKey().equals("")) {
                    final ResourcePath subPath = resourcePath(subRoute.getKey());
                    try {
                        readInstances(context, result.get("result"), subPath, subRoute.getValue());
                    } catch (ResourceException e) {
                        return e.asPromise();
                    }
                }
            }
            return newActionResponse(result).asPromise();
        } else if (GET_ALL_TYPES.equals(action) && remainingUri.isEmpty()) {
            try {
                return readTypes(context, ALL_CHILD_TYPES, false);
            } catch (ResourceException e) {
                return e.asPromise();
            }
        } else if (GET_CREATABLE_TYPES.equals(action) && remainingUri.isEmpty()) {
            try {
                return readTypes(context, NOT_CREATED_SINGLETONS, forUI);
            } catch (ResourceException e) {
                return e.asPromise();
            }
        } else {
            return router.handleAction(context, request);
        }
    }

      SmsRouteTree(Map<MatchingResourcePath, CrestAuthorizationModule> authzModules,
            CrestAuthorizationModule defaultAuthzModule, boolean isRoot, Router router, Filter filter,
            ResourcePath path, Predicate<String> handlesFunction, String uriTemplate);

}