Added callback in tree traversal function