Make tree function accept a dir arg