This function is recursive, but when it returns the result is ultimately undefined because it is going up the stack of recursive calls when finally return is reached.