Json lookup by dynamic path

I’m loading a json file and I need to dynamically lookup a path in the tree. Eg say I have the following json in file.json:

  "some1": {
     "path1": {
        "key1": value1

If I loaded this into a local called json then I could write local.json.some1.path1.key1 to get value1. But I need the path to be an input. The following does not work:

locals {
  tree = jsondecode("file.json")
  path = "some1.path1.key1"
  value1 = local.tree[local.path]

I dont think it is possible to do this. I tried a few things with lookup, etc, no luck. Any ideas?