For_each over a list of maps

Anyone know how to for_each over a list that does not have a flat shape and looks like the following? I want to create multiple resources. Unable to find anything in the for_each docs except simple examples.

hosts = [
{
hostname                 = "host1"
interface =  {
  leafs =  [{
    device = "en0”
    ip       = "X.X.X.X"
    netmask  = "/24"
    gateway  = "10.X.X.1"
   },
  { device    = "en1"
    ip       = "X.X.X.X"
    netmask  = "/24"
    gateway  = "10.X.X.1"
   }],
  lom = { ip = "X.X.X.X" },
  management = {
    device    = "en2"
    ip        = "X.X.X.X"
    netmask   = "/24"
    gateway   = "X.X.X.1"
    mac       = "aa:bb:cc:dd:ee:ff"
  },
  stable = {
    device = "lo"
    ip     = "x.x.x.x"
  },
}
another_variable   = "value1”,
a_list   = [ "value1", "value2" ]
},
{
..
..
..

You nest two for expressions to deal with the two levels of nesting, and then you use merge() to flatten the resulting list of maps into a single map containing all the entries - e.g. Multiple iteration in one resource - #2 by maxb