title: javascript extract same values of keys from array of objects
body: <p>I have hundreds of objects inside each other
  and under each object there is a repeated object structure with an object inside that contains hundred of keys that are the same and in most of the keys the values are the same also.</p>
  
  <p>What I would like to do is to get from this repeated object the key and value only if its the same across all over the objects and put it aside in an new object that contains all the same repeated pairs of key/value while also remove it from that repeated object inside of every one of the objects.</p>
  
  <p>json objects for example:</p>
  
  <pre><code>[{
      "name": "A",
      "values": {
          "ab": "abc",
          "ac": "1",
          "ad": "none"
      },
      "childs": []
  },
  {
      "name": "A",
      "values": {
          "ab": "abc",
          "ac": "1",
          "ad": "none"
      },
      "childs": [{
          "name": "B",
          "values": {
              "ab": "abc",
              "ac": "1",
              "ad": "none"
          },
          "childs": [{
                  "name": "C",
                  "values": {
                      "ab": "abc",
                      "ac": "1",
                      "ad": "none"
                  },
                  "childs": []
              },
              {
                  "name": "C",
                  "values": {
                      "ab": "def",
                      "ac": "1",
                      "ad": "none"
                  },
                  "childs": []
              }
          ]
      }]
  },
  {
      "name": "A",
      "values": {
          "ab": "abc",
          "ac": "1",
          "ad": "none"
      },
      "childs": [{
          "name": "D",
          "values": {
              "ab": "abc",
              "ac": "1",
              "ad": "none"
          },
          "childs": []
      }]
  }]
  </code></pre>
  
  <p>desired output:</p>
  
  <pre><code>[{
      "name": "A",
      "values": {
          "ab": "abc"
      },
      "childs": []
  },
  {
      "name": "A",
      "values": {
          "ab": "abc"
      },
      "childs": [{
          "name": "B",
          "values": {
              "ab": "abc"
          },
          "childs": [{
                  "name": "C",
                  "values": {
                      "ab": "abc"
                  },
                  "childs": []
              },
              {
                  "name": "C",
                  "values": {
                      "ab": "def"
                  },
                  "childs": []
              }
          ]
      }]
  },
  {
      "name": "A",
      "values": {
          "ab": "abc"
      },
      "childs": [{
          "name": "D",
          "values": {
              "ab": "abc"
          },
          "childs": []
      }]
  }]
  </code></pre>
  
  <p>and a new object contains the key/value pairs that were removed because they are the same:</p>
  
  <pre><code>[{
      "ac": "1",
      "ad": "none"
  }]
  </code></pre>