private function checkForUselessNodes(SimpleXMLElement $resource, $data)
    {
        $uselessNodes = [];
        foreach ($resource as $key => $value) {
            if (!array_key_exists($key, $data)) {
                $uselessNodes[] = $key;
            }
        }
        foreach ($uselessNodes as $key) {
            unset($resource->$key);
        }
    }