remove some unnecessary type declarations
prevent cycles when adding elements as children
fix comments
add simple special case
add some tests for no-op cases in addprevious() / addnext()