Generalized the tree script to allow an optional directory path