Fixed condition check on item existence in list

Previously, 'set $path...' ran regardless of the result of 'and not contains...'. This fixes _append_path to actually use the result of the condition check.