This one works for both leaves and nodes, scalars and arrays. author: Bhakti Mehta (bhakti.mehta@sun.com)