Repository: mathandy/svgpathtools

Issue:
Document does not add path to empty group
When the passed group element has no children, `Document.add_path` incorrectly adds the path to the root element.

Example:
```python
doc = Document()
empty = doc.add_group(group_attribs={"id": "empty"})
doc.add_path("M 0,0 L 1,1", group=empty)
print(doc)
```
Output:
```svg
<svg xmlns:svg="http://www.w3.org/2000/svg"><svg:g id="empty" /><path d="M 0,0 L 1,1" /></svg>
```

Expected Output:
```svg
<svg xmlns:svg="http://www.w3.org/2000/svg"><svg:g id="empty"><path d="M 0,0 L 1,1" /></svg:g></svg>
```

Discussion:
mathandy: Looks good.  Thanks @[chanicpanic](https://github.com/chanicpanic)!

Patch:
diff --git a/svgpathtools/document.py b/svgpathtools/document.py
index f88f5ba..1dd9077 100644
--- a/svgpathtools/document.py
+++ b/svgpathtools/document.py
@@ -289,7 +289,7 @@ class Document:
 
         # If given a list of strings (one or more), assume it represents
         # a sequence of nested group names
-        elif all(isinstance(elem, str) for elem in group):
+        elif len(group) > 0 and all(isinstance(elem, str) for elem in group):
             group = self.get_or_add_group(group)
 
         elif not isinstance(group, Element):


Test patch:
diff --git a/test/test_groups.py b/test/test_groups.py
index 44b6cb9..aeb3393 100644
--- a/test/test_groups.py
+++ b/test/test_groups.py
@@ -235,4 +235,11 @@ class TestGroups(unittest.TestCase):
 
         path = parse_path(path_d)
         svg_path = doc.add_path(path, group=new_leaf)
-        self.assertEqual(path_d, svg_path.get('d'))
\ No newline at end of file
+        self.assertEqual(path_d, svg_path.get('d'))
+
+        # Test that paths are added to the correct group
+        new_sibling = doc.get_or_add_group(
+            ['base_group', 'new_parent', 'new_sibling'])
+        doc.add_path(path, group=new_sibling)
+        self.assertEqual(len(new_sibling), 1)
+        self.assertEqual(path_d, new_sibling[0].get('d'))