private Object fromNode ( final ImmutableNode node ) { if ( ! node . getChildren ( ) . isEmpty ( ) ) { final Map < String , List < ImmutableNode > > children = getChildrenWithName ( node ) ; final HashMap < String , Object > map = new HashMap <> ( ) ; for ( final Map . Entry < String , List < ImmutableNode > > entry : children . entrySet ( ) ) { assert ! entry . getValue ( ) . isEmpty ( ) ; if ( entry . getValue ( ) . size ( ) == 1 ) { // Just one node. final ImmutableNode child = entry . getValue ( ) . get ( 0 ) ; final Object childValue = fromNode ( child ) ; map . put ( entry . getKey ( ) , childValue ) ; } else { // Multiple nodes. final ArrayList < Object > list = new ArrayList <> ( ) ; for ( final ImmutableNode child : entry . getValue ( ) ) { final Object childValue = fromNode ( child ) ; list . add ( childValue ) ; } map . put ( entry . getKey ( ) , list ) ; } } return map ; } else { return node . getValue ( ) ; } }
Gets a serialization object from a node .