This method creates a new group.

        A group title is needed or no group will be created.

        If a parent is given, the group will be created as a sub-group.

        title must be a string, image an unsigned int >0 and parent a Group.
        
        :return: The newly created group.
        :rtype: :class:`keepassdb.model.Group`

def create_group(self, title, parent=None, icon=1, expires=None):
        """
        This method creates a new group.

        A group title is needed or no group will be created.

        If a parent is given, the group will be created as a sub-group.

        title must be a string, image an unsigned int >0 and parent a Group.
        
        :return: The newly created group.
        :rtype: :class:`keepassdb.model.Group`
        """
        if parent and not isinstance(parent, Group):
            raise TypeError("Parent must be of type Group")
        
        if expires is None:
            expires = const.NEVER
        
        if self.groups:
            group_id = max([g.id for g in self.groups]) + 1
        else:
            group_id = 1
        
        group = Group(id=group_id, title=title, icon=icon, db=self, 
                      created=util.now(), modified=util.now(), accessed=util.now(),
                      expires=expires)
        
        # If no parent is given, just append the new group at the end
        if parent is None:
            group.parent = self.root
            self.root.children.append(group)
            group.level = 0
            self.groups.append(group)
            
        # Else insert the group behind the parent
        else:
            if parent not in self.groups:
                raise ValueError("Group doesn't exist / is not bound to this database.")
            parent.children.append(group)
            group.parent = parent
            group.level = parent.level + 1
            self.groups.insert(self.groups.index(parent) + 1, group)
                
        return group