Merge a multidimensional array
Ok, I managed to figure it out following directions on this page:
Creating dynamic array and set keys

{% set filmData = { "film" : film.title, "url" : film.url, "starts" : starts, "ends" : ends, "length" : film.length } %}

{% if not attribute(screeningsForTheater, screening.theater.label) is defined %}

    {% set screeningsForTheater = screeningsForTheater | merge({ (screening.theater.label) : [filmData] }) %}

{% else %}

    {% set otherFilms = attribute(screeningsForTheater, screening.theater.label) %}
    {% set otherFilms = otherFilms | merge([filmData]) %}
    {% set screeningsForTheater = screeningsForTheater|merge({ (screening.theater.label) : otherFilms }) %}

{% endif %}


EDIT

However I realized I had to create another level to the array by including the date of the screening. This was the format needed:

screenings = {
  "22.3.2018" : {
    "Theater 1" : {
      "Movie 1" : { ... },
      "Movie 2" : { ... }
    },
    "Theater 2" : {
      "Movie 3" : { ... },
      "Movie 4" : { ... }
    }
  },
  "23.3.2018" : {
    "Theater 1" : {
      "Movie 5" : { ... },
      "Movie 6" : { ... }
    },
    "Theater 2" : {
      "Movie 7" : { ... },
      "Movie 8" : { ... }
    }
  }
}


I spent some time trying to create this kind of array using twig, but couldn't get the merge to work correctly.

I then created a plugin and a templateVariable to do the search and array stuff using PHP, which was a lot more comfortable, and got this working in no time.