Fixed duplication of children in parent's collection during flushing. #379

Fixed duplication of children in parent's collection during flushing. #379

Fix indentation issues
Merge pull request #390 from sarcher/issue-379-tests

Resolve duplication issue when adding children to a parent's collection #379