Is trimAllowedNodes modifying the pathfinder object? Since it already works as a const reference, the answer is likely no. Unless the function is specified to (possibly) modify the parameter, you want const to avoid incidental bugs from accidentally modifying objects.