### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

When defining path parameter resources, for example:

 * `/documents/{documentId+}`
 * `/documents/search`

In CDK, the order of definition changes what LocalStack returns. If you define the path parameter `/documents/{documentId+}` before `/documents/search` and then try to hit `/documents/search`, LocalStack instead invokes the integration for `/documents/{documentId+}`, rather than the intended one.

However, if you define `/documents/search` before `/documents/{documentId+}` in CDK, LocalStack invokes the correct integration.

### Expected Behavior

In AWS, the order does not matter, and no matter which order they're defined in trying to hit `/document/search` will result in the integration for that resource being invokes.

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

#### How are you starting localstack (e.g., `bin/localstack` command, arguments, or `docker-compose.yml`)

    docker run localstack/localstack

#### Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

```ts
export class GatewayStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const api = new RestApi(this, "test-api", {
      restApiName: "test-api",
    });

    const getByIdLambda = new Function(this, "get-by-id-handler", {
      runtime: Runtime.NODEJS_20_X,
      code: Code.fromInline(
        "exports.handler = async () => ({ statusCode: 200, body: 'Get By Id' });",
      ),
      handler: "index.handler",
    });

    const searchLambda = new Function(this, "search-lambda-handler", {
      runtime: Runtime.NODEJS_20_X,
      code: Code.fromInline(
        "exports.handler = async () => ({ statusCode: 200, body: 'Search Results' });",
      ),
      handler: "index.handler",
    });

    const documents = api.root.addResource("document");
    const getById = documents.addResource("{documentId+}");
    const search = documents.addResource("search");

    getById.addMethod("GET", new LambdaIntegration(getByIdLambda));
    search.addMethod("GET", new LambdaIntegration(searchLambda));
  }
}
```

```sh
GATEWAY_ID=$(awslocal apigateway get-rest-apis --query "items[0].id" --output text)
curl https://$GATEWAY_ID.execute-api.localhost.localstack.cloud:4566/prod/document/search
```

### Environment

```markdown
- OS: Ubuntu 20.04
- LocalStack: 3.1
```


### Anything else?

I've reproduced the issue here: https://github.com/Garethp/localstack-bugs/tree/order-dependant-path-parts
If you clone down the branch `order-dependant-path-parts`, run `yarn install` and then `./start.sh` you should see the issue in action
with self._pathctx(namespace):
            return self._resolve_references(data)
    def _resolve_references(self, data) -> Union[dict, list]:
        if self._is_ref(data):
            return self._resolve_refpath(data["$ref"])
        if isinstance(data, dict):
            for k, v in data.items():
                data[k] = self._namespaced_resolution(k, v)
        elif isinstance(data, list):
            for i, v in enumerate(data):
                data[i] = self._namespaced_resolution(str(i), v)
        return data
    def resolve_references(self) -> dict:
        return self._resolve_references(self.document)
class ModelResolver:
    """
    This class allows a Model to use recursive and circular references to other Models.
    To be able to JSON dump Models, AWS will not resolve Models but will use their absolute $ref instead.
    When validating, we need to resolve those references, using JSON schema tricks to allow recursion.
    See: https://json-schema.org/understanding-json-schema/structuring.html#recursion
    To allow a simpler structure, we're not replacing directly the reference with the schema, but instead create
    a map of all used schema in $defs, as advised on JSON schema:
    See: https://json-schema.org/understanding-json-schema/structuring.html#defs
    This allows us to not render every sub schema/models, but instead keep a clean map of used schemas.
    """
    def __init__(self, rest_api_container: RestApiContainer, model_name: str):