def find_routes(routes, uri, decomposed_uri=None):
    """ Returns routes matching the given URL.
    """
    sub_num = 0
    uri_no_sub = None
    if decomposed_uri is not None:
        uri_no_sub, sub_num = decomposed_uri
    res = []
    for route in routes:
        route_params = route.matchUri(uri)
        if route_params is not None:
            res.append((route, route_params, 1))
    if sub_num > 1:
        for route in routes:
            route_params = route.matchUri(uri_no_sub)
            if route_params is not None:
                res.append((route, route_params, sub_num))
    return res
