add parent to buildChildren function, remove unused code