Performance fix WorkingTree.getTree() and Index.getTree()

Both methods were forcing an update to the ref database even if not
needed, making calls inside loops too resource consuming esp. since
FileRefDatabase calls on File.syc().