Added walkTree util function.