Minor code refactor around adding different layouts to parent

Removed repeated code as much as possible in the if/else chain to be
more DRY.