def to_hash
      as_hash = Hash.new
      unless children?
        if self.is_a?(DObject)
          as_hash = {}
        else
          as_hash[(self.tag.private?) ? self.tag : self.send(DICOM.key_representation)] = nil
        end
      else
        children.each do |child|
          if child.tag.private?
            hash_key = child.tag
          elsif child.is_a?(Item)
            hash_key = "Item #{child.index}"
          else
            hash_key = child.send(DICOM.key_representation)
          end
          if child.is_a?(Element)
            as_hash[hash_key] = child.to_hash[hash_key]
          else
            as_hash[hash_key] = child.to_hash
          end
        end
      end
      return as_hash
    end
def to_hash
      as_hash = Hash.new
      unless children?
        if self.is_a?(DObject)
          as_hash = {}
        else
          as_hash[(self.tag.private?) ? self.tag : self.send(DICOM.key_representation)] = nil
        end
      else
        children.each do |child|
          if child.tag.private?
            hash_key = child.tag
          elsif child.is_a?(Item)
            hash_key = "Item #{child.index}"
          else
            hash_key = child.send(DICOM.key_representation)
          end
          if child.is_a?(Element)
            as_hash[hash_key] = child.to_hash[hash_key]
          else
            as_hash[hash_key] = child.to_hash
          end
        end
      end
      return as_hash
    end
Builds a nested hash containing all children of this parent.

 Keys are determined by the key_representation attribute, and data element values are used as values.
 * For private elements, the tag is used for key instead of the key representation, as private tags lacks names.
 * For child-less parents, the key_representation attribute is used as value.

 @return [Hash] a nested hash containing key & value pairs of all children