support -p parameter, keep at most N level of path