def add_group(opts)
      raise ArgumentError, "Expected Hash or Keepassx::Group, got #{opts.class}" unless valid_group?(opts)

      if opts.is_a?(Keepassx::Group)
        # Assign parent group
        parent = opts.parent
        index  = last_sibling_index(parent) + 1
        @groups.insert(index, opts)

        # Increment counter
        header.groups_count += 1

        # Return group
        opts

      elsif opts.is_a?(Hash)
        opts = deep_copy(opts)
        opts = build_group_options(opts)

        # Create group
        group = create_group(opts)

        # Increment counter
        header.groups_count += 1

        # Return group
        group
      end
    end
def add_group(opts)
      raise ArgumentError, "Expected Hash or Keepassx::Group, got #{opts.class}" unless valid_group?(opts)

      if opts.is_a?(Keepassx::Group)
        # Assign parent group
        parent = opts.parent
        index  = last_sibling_index(parent) + 1
        @groups.insert(index, opts)

        # Increment counter
        header.groups_count += 1

        # Return group
        opts

      elsif opts.is_a?(Hash)
        opts = deep_copy(opts)
        opts = build_group_options(opts)

        # Create group
        group = create_group(opts)

        # Increment counter
        header.groups_count += 1

        # Return group
        group
      end
    end
Add new group to database.

 @param opts [Hash] Options that will be passed to Keepassx::Group#new.
 @return [Keepassx::Group]
 rubocop:disable Metrics/MethodLength