[bugfix] log_series: avoid infinite recursion

Check if the argument is on a branch cut check if it actually depends
on the expansion variable before trying to expand around a different
point in order to avoid the infinite recursion (or rather a segfault
due to a stack overflow).

Thanks to Mario Prausa for a bugreport.