Fixed issue when staging using path filter (fixes #317)

If the tree represented by the path filter had itself changed, it was not correctly added. This commit fixes that problems, and now the corresponding tree is added to the list of unstaged elements when needed