remove some redundant returns and conditionals from recursions