#get all paths and groups from selection. Remove all groups from the selection and form a new single group of it
defparseNodes(self,node):
ifnode.tag==inkex.addNS('path','svg'):
ifnodenotinself.allPaths:
self.allPaths.append(node)
ifnode.tag==inkex.addNS('g','svg'):
groups=node.getchildren()
ifgroupsisnotNone:
forgroupingroups:
parseNodes(self,group)
ifgroupnotinself.allGroups:
self.allGroups.append(group)
forid,iteminself.svg.selected.items():
parseNodes(self,item)
iflen(self.allPaths)>0:
#make a new group at root level - TODO: respect the position where the first selected object is in XML tree and put it there instead (or make this optional)