def move_group(self, group, parent, index=None):
        """
        Move group to be a child of new parent.
        
        :param group: The group to move.
        :type group: :class:`keepassdb.model.Group`
        :param parent: The new parent for the group.
        :type parent: :class:`keepassdb.model.Group`
        :param index: The 0-based index within the parent (defaults to appending
                      group to end of parent's children).
        :type index: int
        """
        if not isinstance(group, Group):
            raise TypeError("group param must be of type Group")
        
        if parent is not None and not isinstance(parent, Group):
            raise TypeError("parent param must be of type Group")
            
        if group is parent:
            raise ValueError("group and parent are the same")
            
        if parent is None:
            parent = self.root
        elif parent not in self.groups:
            raise exc.UnboundModelError("Parent group doesn't exist / is not bound to this database.")
            
        if group not in self.groups:
            raise exc.UnboundModelError("Group doesn't exist / is not bound to this database.")
        
        curr_parent = group.parent
        curr_parent.children.remove(group)
        
        if index is None:
            parent.children.append(group)
            self.log.debug("Moving {0!r} to child of {1!r}, (appending)".format(group, parent))
        else:
            parent.children.insert(index, group)
            self.log.debug("Moving {0!r} to child of {1!r}, (at position {2!r})".format(group, parent, index))
        
        #Recurse down and reset level of all moved nodes
        def set_level(g):
            g.level = g.parent.level + 1
            for child in g.children:
                set_level(child)

        group.parent = parent
        set_level(group)
        group.modified = util.now()
        
        self._rebuild_groups()