Set parent of new node [backport]

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Remove redundant parentheses

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Make methods static when possible

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Remove unused imports

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Added missing self parameter

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Use Pythonic comparison for range

Signed-off-by: Stefan Marr <git@stefan-marr.de>