NodeJS tree structure for functions