$backtrace = debug_backtrace();
$backtrace = serialize($backtrace);
$backtrace = unserialize($backtrace);
EDIT: Okay, so this isn't a complete solution.
It works for recursive objects references (they are lost) but not
for recursive arrays (they are retained).
My current solution is to serialize/unserialize as above, and
then run the resulting array through a recursion-detection function
such as that described here: http://www.php.net/manual/en/ref.array.php#96914