ad-substitute-tree is a compiled Lisp function in `advice.el'.

(ad-substitute-tree SUBTREE-TEST FUNCTION TREE)

Substitute qualifying subTREEs with result of FUNCTION(subTREE).
Only proper subtrees are considered, for example, if TREE is (1 (2 (3)) 4)
then the subtrees will be 1 (2 (3)) 2 (3) 3 4, dotted structures are
allowed too. Once a qualifying subtree has been found its subtrees will
not be considered anymore. (ad-substitute-tree 'atom 'identity tree)
generates a copy of TREE.