added recusive permutation function
updated n_permutations to support recursive structures
removed print statement