Added maximum depth parameter when building tree.