Shouldn't this if be around the for? Otherwise it seems you are looping for nothing if mk_parents is false