Refactor setting parent in a private way.