Java 7, 153 bytes
String r="";String c(int i,Object[]o){for(Object x:o)if(x instanceof Object[])c(i+1,(Object[])x);else{for(int j=i;j-->0;r+="-");r+=">"+x+"\n";}return r;}
Explanation:
String r=""; // Result String outside the method / on class-level
String c(int i, Object[] a){ // Recursive Method with integer and Object-array parameters and String return-type
for(Object x : o) // Loop over the input-array
if(x instanceof Object[]) // If the current item is an array itself:
c(i+1, (Object[])x); // Recursive method-call with this array
else{ // Else:
for(int j=i;j-->0;r+="-"); // Append the result-String with `i` times "-"
r += ">"+x+"\n"; // Append the result-String with ">", the current item, and a new-line
} // End of if-else
// End of for-loop (implicit / single-line body)
return r; // Return the result-String
} // End of method
Test code:
Try it here.
class M{
String r="";String c(int i,Object[]o){for(Object x:o)if(x instanceof Object[])c(i+1,(Object[])x);else{for(int j=i;j-->0;r+="-");r+=">"+x+"\n";}return r;}
public static void main(String[] a){
M m = new M();
System.out.println(m.c(0, new Object[]{new Object[]{1,2},new Object[]{new Object[]{1,2},3},4,new Object[]{new Object[]{new Object[]{new Object[]{5}}},6}));
m.r = "";
System.out.println(m.c(0, new Object[]{"Atom",new Object[]{"Proton",new Object[]{"Up Quark","Up Quark","Down Quark"}},new Object[]{"Neutron",new Object[]{"Up Quark","Up Quark","Down Quark"}},"Electron"}));
}
}
Output:
->1
->2
-->1
-->2
->3
>4
---->5
>6
>Atom
->Proton
-->Up Quark
-->Up Quark
-->Down Quark
->Neutron
-->Up Quark
-->Up Quark
-->Down Quark
>Electron