Definitions for nested tree functions