Recursion, use a extra vector to record visited element to avoid duplicate