deduce type of recursively called function invocation