title: convert nested object to csv where all parents of lowest properties are visible on individual lines
body: <p>I have a nested object that I want to to transform to flat lines. Below is the object:</p>
  <pre><code>    {
        &quot;United States&quot;: {
          &quot;New York&quot;: {
            &quot;first&quot;: 11,
            &quot;second&quot;: 7
          },
          &quot;New Jersey&quot;: {
            &quot;first&quot;: 8,
            &quot;second&quot;: 2
          },
          &quot;Pennsylvania&quot;: {
            &quot;first&quot;: 4,
            &quot;second&quot;: 2
          }
        }
      },
      {
        &quot;South America&quot;: {
          &quot;Brazil&quot;: {
            &quot;first&quot;: 5,
            &quot;second&quot;: 4
          }
        }
      },
      {
        &quot;Africa&quot;: {
          &quot;Zaire&quot;: {
            &quot;first&quot;: 2,
            &quot;second&quot;: 1
          }
        }
      },
      {
        &quot;Asia&quot;: {
          &quot;China&quot;: {
            &quot;first&quot;: 10,
            &quot;second&quot;: 4
          },
          &quot;Japan&quot;: {
            &quot;first&quot;: 6,
            &quot;second&quot;: 3
          }
        }
      },
      {
        &quot;Eastern Europe&quot;: {
          &quot;Ukraine&quot;: {
            &quot;first&quot;: 2,
            &quot;second&quot;: 1
          }
        }
      },
      {
        &quot;Europe&quot;: {
          &quot;France&quot;: {
            &quot;first&quot;: 2,
            &quot;second&quot;: 4
          },
          &quot;Germany&quot;: {
            &quot;first&quot;: 1,
            &quot;second&quot;: 7
          },
          &quot;Portugal&quot;: {
            &quot;first&quot;: 3,
            &quot;second&quot;: 1
          },
          &quot;Spain&quot;: {
            &quot;first&quot;: 5,
            &quot;second&quot;: 2
          },
          &quot;Switzerland&quot;: {
            &quot;first&quot;: 1,
            &quot;second&quot;: 3
          }
        }
      }
  </code></pre>
  <p>I want to be able to see it like this, where the top level of the nest is always visible for each line:</p>
  <pre><code>    &quot;United States&quot;, &quot;New York&quot;, 11, 7
      &quot;United States&quot;, &quot;New Jersey&quot;, 8, 2
      &quot;United States&quot;, &quot;Pennsylvania&quot;, 4, 2
      &quot;South America&quot;:, &quot;Brazil&quot;, 5, 4
      &quot;Africa&quot;, &quot;Zaire&quot;, 2, 1
      &quot;Asia&quot;, &quot;China&quot;, 10, 4
      &quot;Asia&quot;, &quot;Japan&quot;, 6, 3
      &quot;Eastern Europe&quot;, &quot;Ukraine&quot;, 2, 1
      &quot;Europe&quot;, &quot;France&quot;, 2, 4
      &quot;Europe&quot;, &quot;Germany&quot;, 1, 7
      &quot;Europe&quot;, &quot;Portugal&quot;, 3, 1
      &quot;Europe&quot;, &quot;Spain&quot;, 5, 2
      &quot;Europe&quot;, &quot;Switzerland&quot;, 1, 3
  </code></pre>
  <p>I know how to loop through arrays to do this, but I'm not sure how to achieve it with a nested object. I've searched s/o, but haven't seen anything that quite achieves this.
  (My actual data set is much longer)
  Any help is very welcome. Thank you.</p>